如何在struts2-core 2.3.16.1上访问ServletRequestAware?

问题描述 投票:0回答:2

我将struts2版本从2.3.14更改为2.3.16.1,似乎最新版本不再支持

ServletRequestAware
ServletResponseAware
,我该怎么办?我在网上找不到任何东西。

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

代码

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

错误

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

当我尝试找到它的依赖项时,Maven 显示支持它的 Struts2 的最新版本是 2.3.14!

servlets struts2 struts2-interceptors
2个回答
0
投票

您的项目中包含的库可能存在一些问题;

  • 确保从类路径中删除所有旧的 JAR(您的 WAR / EAR 和 AS 上的共享库;
  • 在 IDE 中运行 Clean Project;
  • 从 Maven 下载 Struts2.3.16.1 或手动从这里;
  • 查看

    ServletRequestAware
    ServletResponseAware
    界面:

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

    ,就在他们之前的位置;)

例如,2.3.16.3 发行版的输出:

$ 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

它也在 2.3.16.1 jars 中。


0
投票

在欢迎使用 Struts2 的第 3 步将以下依赖项添加到您的

pom.xml

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

检查存储库中可用的文件版本 X.X.X.X 并下载到您的硬盘上。

© www.soinside.com 2019 - 2024. All rights reserved.