struts2 2.5.16 通配符方式调用action中的方法报404
1、问题描述
在struts.xml中配置用通配符方式调用action中的add()方法,访问 http://localhost:8080/Struts2Demo/helloworld_add.action时,出现了这个熟悉的错误:
HTTP Status 404 – Not Found
Type Status Report
Message There is no Action mapped for namespace [/] and action name [helloworld_add] associated with context path [/Struts2Demo].
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.35
2、相关代码
struts.xml中部分相关代码
<package name="default" namespace="/" extends="struts-default">
<action name="helloworld_*" method="{1}" class="com.icheny.action.HelloWorldAction">
<result>/result.jsp</result>
<result name="add">/{1}.jsp</result>
<result name="update">/{1}.jsp</result>
</action>
</package>
HelloWorldAction.java中部分相关代码
public String add()
{
return "add";
} public String update()
{
return "update";
}
3、原因
由于struts2 2.5版本的安全度提高了一个台阶,通配符禁止使用,所有不安全的访问都必须要在struts.xml中声明允许。我用的是2.5.16版本的struts,因此出现了这个错误。
4、解决方案
在package中添加属性:strict-method-invocation="false"
修改之后的struts.xml中的package部分代码为:
<package name="default" namespace="/" extends="struts-default" strict-method-invocation="false">
<action name="helloworld_*" method="{1}" class="com.icheny.action.HelloWorldAction">
<result>/result.jsp</result>
<result name="add">/{1}.jsp</result>
<result name="update">/{1}.jsp</result>
</action>
</package>
再次访问http://localhost:8080/Struts2Demo/helloworld_add.action,正常跳转:

struts2 2.5.16 通配符方式调用action中的方法报404的更多相关文章
- struts2 利用通配符方式解决action太多的问题
<!-- 创建包default,继承struts-default --> <package name="default" extends="str ...
- Action中动态方法的调用 Action中通配符的使用 Result的配置
Action中动态方法的调用 动态方法调用(Dynamic Method Invocation,DMI) 标识符:! 一.通过以下选中的文件来查看是否禁止调用动态方法
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
- Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。
1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...
- mybatis-plus调用自身的 selectById 方法报错:org.apache.ibatis.binding.BindingException:
mybatis-plus的版本号是 2.0.1,在调用自身的insert(T)的时候没有报错,但是执行update报错,调用selectById.deleteById的时候也报错.也就是涉及到需要主键 ...
- 在action中进行文件下载,下载时运行不报错,可是也不下载
在写前端下载页面时,使用ajax方式调用action中的方法,然后就将下载内容返回js中了,所以没有下载,之后改为使用Windows.location进行下载,就没有问题了. action中代码: i ...
- struts2的占位符*在action中的配置方法
转自:https://blog.csdn.net/u012546338/article/details/68946633 在配置<action> 时,可以在 name,class,meth ...
- Struts2(五.用户注册的实现及整合Action的配置方法)
一.用户注册功能 register.jsp页面 若是jquery ajax方式提交给action,还要回到jquery,控制权在jquery若是表单方式提交给action,控制权交给action &l ...
- struts2:数据校验,通过Action中的validate()方法实现校验(续:多业务方法时的不同验证处理)
前文:struts2:数据校验,通过Action中的validate()方法实现校验,图解 如果定义的Action中存在多个逻辑处理方法,且不同的处理逻辑可能需要不同的校验规则,在这种情况下,就需要通 ...
随机推荐
- java http httpclient
HttpClient post get 洗衣店 微信扫码支付
- Web Api 接口返回值不困惑:返回值类型详解
前言:已经有一个月没写点什么了,感觉心里空落落的.今天再来篇干货,想要学习Webapi的园友们速速动起来,跟着博主一起来学习吧.之前分享过一篇 WebApi 接口参数:传参详解,这篇博文内容本身很基础 ...
- python 多线程、线程锁、事件
1. 多线程的基本使用 import threading import time def run(num): print('Num: %s'% num) time.sleep(3) if num == ...
- python _str_方法
_str_方法: 使用:如: class Car: def __init__(self,newWheelNum,newColor): self.wheelNum=newWheelNum self.co ...
- gitlab docker中postgresql远程访问配置
1.配置postgresql远程访问 配置postgresql远程访问,需要修改两个文件,在gitlab-ce的docker中位置为 /var/opt/gitlab/postgresql/data 首 ...
- tf.split( )和tf.unstack( )
import tensorflow as tf A = [[1, 2, 3], [4, 5, 6]] a0 = tf.split(A, num_or_size_splits=3, axis=1)#不改 ...
- python+selenium封装UI自动化框架
seleinum框架 框架的思想: 解决我们测试过程中的问题:大量的重复步骤,用自动化来实现 1)配置和程序的分离 2)测试数据和程序的分离 3)不懂编程的人员可以方便使用:使用的 ...
- Linux基础教程 linux中使用find命令搜索文件常用方法记录
find是linux非常强大的搜索命令,通过man find查看find手册,可以发现find的说明一屏接一屏,估计要看完也得花不少时间.兄弟连Linux培训 小编总结了下,整理出find常用的使用方 ...
- 网页设计之js
1.JavaScript概述 javaScript与ECMAScript的相爱相杀 1996年11月,JavaScript的创造者--Netscape公司,决定将JavaScript提交给国际标准化组 ...
- 一个ros包依赖另一个ros包提供的库
背景: 编写一个点云配准的ros包,记为A,在其中打算使用多种点云配准算法. 同一个ros工作空间下有另一个ros包,记为B,B中提供了几种点云配准算法,并将它们都编译成一个库文件并安装在工作空间中. ...