首页 > 代码库 > struts2
struts2
调用动态方法的3中方法
I:可以通过在action属性指定方法调用
II:官方推荐使用
<action name="userLogin_*" class="com.wangsl.action.UserAction" method="{1}"> 红色标识是一一对应的,可以给予请求url直接指定方法名,
<result name="success">/default.jsp</result>
</action>
的形式,需要在 <constant name="struts.enable.DynamicMethodInvocation" value="http://www.mamicode.com/false"/>配置一下即可,
在struts 2.5版本中会报 **not allowanced的错误,
只需要在action同级目录中添加
<global-allowed-methods>regex:.*</global-allowed-methods>即可.
III: 另外一种方法不推荐使用,请求url形如 http://localhost:8080/项目名/命名空间/actionName!方法名的形式,但是需要配置
<constant name="struts.enable.DynamicMethodInvocation" value="http://www.mamicode.com/true"/>
,如果匹配不到namespace及action,也需要配置一下<global-allowed-methods>regex:.*</global-allowed-methods>即可.
struts2
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。