在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>

相关文章:

  • 2021-04-12
  • 2021-04-26
  • 2021-09-16
  • 2021-10-24
  • 2021-05-25
  • 2021-11-07
  • 2021-06-07
  • 2021-08-30
猜你喜欢
  • 2021-07-10
  • 2021-06-05
  • 2022-01-24
  • 2021-10-30
  • 2021-05-22
  • 2021-11-22
  • 2021-04-12
相关资源
相似解决方案