How to have access to ServletRequestAware on struts2-core 2.3.16.1?

不羁的心 提交于 2019-12-08 13:57:53

问题


I changed my struts2 version from 2.3.14 to 2.3.16.1, it seems that newest version does not support ServletRequestAware and ServletResponseAware anymore, what should I do? I could not find anything online.

<dependency>    
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.3.16.1</version>
    <type>jar</type>    
</dependency>

Code

 import org.apache.struts2.interceptor.ServletRequestAware;
 public class MyExample implements ServletRequestAware, ServletResponseAware { 

Error

package org.apache.struts2.interceptor does not exist.

When I try to find a dependency for it Maven shows the latest version of Struts2 which is supporting it is 2.3.14!


回答1:


You probably have some problem with the libraries included in your project;

  • Be sure to erase all the old JARs from the classpath (your WAR / EAR and shared libs on the AS;
  • run Clean Project in your IDE;
  • download Struts2.3.16.1 from Maven or manually from here;
  • check out the ServletRequestAware and ServletResponseAware Interfaces at

    /struts-2.3.16.1/src/core/src/main/java/org/apache/struts2/interceptor/
    

    , exactly where they were before ;)

E.g., output from 2.3.16.3 distribution:

$ jar tvf struts2-core-2.3.16.3.jar | grep ServletRequest
223 Fri May 02 17:23:44 EDT 2014 org/apache/struts2/interceptor/ServletRequestAware.class

It's also in the 2.3.16.1 jars.




回答2:


At the Step 3 of Welcome to Struts2 add the following dependency to your pom.xml

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>X.X.X.X</version>
</dependency>

Check the file version X.X.X.X is available in the repository and downloaded to your hard drive.



来源:https://stackoverflow.com/questions/22600204/how-to-have-access-to-servletrequestaware-on-struts2-core-2-3-16-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!