日期:2014-05-16  浏览次数:20733 次

struts2中web.xml配置问题
建了一个struts2的项目,但是配置文件一直有问题,做的是简单的登录验证,web.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
但是这样的话,部署项目的时候会出现错误:
严重: Error filterStart
2014-4-8 0:00:20 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2Login] startup failed due to previous errors。
如果删除过滤器的话,项目部署就没有问题,可是只能跳到index.jsp(一共三个页面:index.jsp,success.jsp,error,jsp)到底怎么回事?我也不知道是不是struts.xml配置的也有问题,还请各位指教!
------解决方案--------------------
用这个org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter代替org.apache.struts2.dispatcher.FilterDispatcher