具体错误如下:
严重: Allocate exception for servlet struts2 java.lang.ClassCastException: org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to javax.servlet.Servlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760) at java.lang.Thread.run(Thread.java:619)
web.xml 配置如下:
struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /*
解决方法: web.xml配置struts2拦截器,不能使用<servlet></servlet>
标签,应该使用<filter></filter>
标签配置,如下:
struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /*
程序能正常访问,问题解决!