在web.xml中配置載入spring時,發現項目無法運行;而去掉spring的配置時,項目可以被初始化。 此時應考慮到spring的配置文件中存在錯誤,以至於web容器無法對項目成功初始化,在web.xml中配置log4j, 根據列印的信息對spring的配置進行修改。 <context-para ...
在web.xml中配置載入spring時,發現項目無法運行;而去掉spring的配置時,項目可以被初始化。
此時應考慮到spring的配置文件中存在錯誤,以至於web容器無法對項目成功初始化,在web.xml中配置log4j,
根據列印的信息對spring的配置進行修改。
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 載入spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>ssm-test-3</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ssm-test-3</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>