使用StrutsPrepareAndExecuteFilter和相关库时没有得到结果

时间:2015-08-10 14:14:49

标签: java maven configuration struts2

当我使用StrutsPrepareAndExecuteFilter

的相关库时

commons-fileupload-1.3.jar, commons-io-2.2.jar, commons-lang-3.1.jar, commons-logging-1.1.3.jar, commons-logging-api-1.1.jar, freemarker-2.3.19.jar, javassist-.3.11.0.GA, ognl-3.0.6.jar, struts2-core-2.3.16.jar, xwork-core.2.3.16.jar

我得到的结果是The requested resource is not available.
web.xml文件是

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://java.sun.com/xml/ns/javaee" 
   xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   id="WebApp_ID" version="2.5">

   <display-name>Struts 2</display-name>
   <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
   <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
   </filter>

   <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-app>

但是当我使用FilterDispatcher和

的相关库时

commons-fileupload-1.2.1.jar, commons-io-1.3.2.jar, commons-lang-2.4.jar, commons-logging-1.0.4.jar, freemarker-2.3.8.jar, javassist, ognl-2.7.3.jar, struts2-core-2.1.8.1.jar, xwork-core.2.1.6.jar

然后我得到了渴望的结果 web.xml文件是

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://java.sun.com/xml/ns/javaee" 
   xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
   id="WebApp_ID" version="3.0">

   <display-name>Struts 2</display-name>
   <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
   <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
         org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
   </filter>

   <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-app>

我不知道自己哪里出错了 有人可以告诉我哪里出错了或者问题是什么。

1 个答案:

答案 0 :(得分:0)

第一个库集中缺少文件commons-lang-2.4.jar。另一个重要的依赖是commons-lang3-3.1.jar。如果使用Maven项目配置,则无需手动配置库。因为struts2-core工件包含所有这些依赖项。

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>X.X.X.X</version>
</dependency>
相关问题