Struts2 奇怪的老是调用index方法

本文详细描述了在使用Struts2时遇到的一个问题,即调用URL时总是尝试调用index方法,导致NoSuchMethodException。通过分析源码,作者发现这是因为Struts2使用了Restful2ActionMapper而非DefaultActionMapper。解决方案是更新struts.properties配置或移除struts2-rest-plugin-2.3.24.jar以避免RestActionMapper的使用。
摘要由CSDN通过智能技术生成

   今天遇到这样一个问题:

调用http://127.0.0.1:8080/StrustTEST2/helloWorld

java.lang.NoSuchMethodException: com.test.strutsAction.HelloWorldAction.index()

 

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
 "http://struts.apache.org/dtds/struts-2.3.dtd">
 <struts>

    <!-- 搜索包路径 -->
 <constant name="struts.convention.package.locators" value="example,strutsAction" />  
</struts>

 

web.xml加入以下属性:

 

<display-name>Struts 2 Rest Example</display-name>

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值