任何人都可以解释我为什么会遇到以下异常:
java.lang.ClassCastException: org.apache.struts2.dispatcher.StrutsRequestWrapper cannot be cast to com.evermind[Oracle Containers
for J2EE 10g (10.1.3.5.0) ].server.http.EvermindHttpServletRequest
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.NotFoundServlet.sendNotFound(NotFoundServlet.java:26
)
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.NotFoundServlet.service(NotFoundServlet.java:18)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
:64)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java
:15)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
当我想拥有NOT_FOUND页面并且我的请求url结束时,我得到它。[some_ext]就像.htm,.blah。但是当请求没有。[some_ext](比如_http:/ domain / part1 / part2 / nosuchurl)那么一切正常,我在struts配置中得到了正常的NOT_FOUND页面映射:
<default-action-ref name="nopagefound"/>
<action name="nopagefound">
<result>/WEB-INF/jsp/errors/notfound.jsp</result>
</action>
我使用Struts2(2.3.1.2)+ Spring部署在oc4j 10.1.3.5.0。
这是我的struts映射:
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在Struts.properties中
struts.action.extension= ,
答案 0 :(得分:0)
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
如果扩展名为.action,则只传递StrutsPrepareAndExecuteFilter,然后就无法获得此异常。并且为了处理404错误,您可以覆盖默认错误页面。