[关闭]
@nextleaf 2018-06-30T02:04:22.000000Z 字数 2022 阅读 1580

SSH整合Demo 排错

SSH 整合


1、org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start

  1. org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start.

到tomcat的logs目录下,打开localhost-时间.log,例如localhost.2018-06-30.log查看;
如果没有或者文件的修改时间不是此时的,尝试手动发布和启动tomcat,再打开该文件查看。

(1)日志中Cannot resolve class 'StrutsPrepareAndExecuteFilter'

解决办法:
Struts2
struts2不同版本核心filter在web.xml中的配置:

查阅官方文档得知:
如果,filter package in Struts >= 2.5,这样配置

  1. <filter>
  2. <filter-name>struts2</filter-name>
  3. <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  4. </filter>
  5. <filter-mapping>
  6. <filter-name>struts2</filter-name>
  7. <url-pattern>/*</url-pattern>
  8. </filter-mapping>

如果,2.1.3<=filter package in Struts < 2.5,这样配置

  1. <filter>
  2. <filter-name>struts2</filter-name>
  3. <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  4. </filter>
  5. <filter-mapping>
  6. <filter-name>struts2</filter-name>
  7. <url-pattern>/*</url-pattern>
  8. </filter-mapping>

如果filter package in Struts < 2.1.3,这样配置

  1. <filter>
  2. <filter-name>struts2</filter-name>
  3. <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  4. </filter>
  5. <filter-mapping>
  6. <filter-name>struts2</filter-name>
  7. <url-pattern>/*</url-pattern>
  8. </filter-mapping>

详细链接IntelliJ IDEA java-web 初学之容易遇到的问题及解决办法

  1. 30-Jun-2018 00:09:32.943 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [struts2]
  2. java.lang.NoClassDefFoundError: ognl/DefaultMemberAccess

(2)日志中NoClassDefFoundError: ognl/DefaultMemberAccess

报错:

  1. 30-Jun-2018 00:09:32.943 严重 [localhost-startStop-1]org.apache.catalina.core.StandardContext.filterStart Exception starting filter[struts2]
  2. java.lang.NoClassDefFoundError: ognl/DefaultMemberAccess
  3. ....
  4. Caused by:java.lang.ClassNotFoundException: ognl.DefaultMemberAccess

既然找不到类,尝试在任意类中

  1. import ognl.DefaultMemberAccess

alt enter
添加依赖项,应该是高版本的ognl并没有DefaultMemberAccess类,将高版本的ognl注释掉。
添加的依赖项为:

  1. <dependency>
  2. <groupId>ognl</groupId>
  3. <artifactId>ognl</artifactId>
  4. <version>3.1.15</version>
  5. <!--<scope>test</scope>-->
  6. </dependency>

<scope>test</scope>注释掉。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注