Struts2 Action下面的Method调用方法
1. 在struts.xml中加入<constant name="struts.enable.DynamicMethodInvocation" value="true" /> 来打开struts中的DMI功能,调用方法为userAction!add
解决使用Struts2.3.16 出现There is no Action mapped for namespace [/user] and action name [user!add] associated with context path错误。
2. 使用通配符
Struts2配置文件中使用通配符收藏
形式一:调用相同Action中的不同方法
<action name="*Action" class="Jcuckoo.LoginRegistAction" method="{1}"> <result name="input">/login.jsp</result> <result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result> </action>
其中表达式{1}的值name属性值中第一个*的值。
如果用户请求的URL为loginAction.action,则调用Jcuckoo.LoginRegistAction中的login方法; 如果用户请求的URL为registerAction.action,则调用Jcuckoo.LoginRegistAction中的register方法;
形式二:通过匹配,调用不同的Action的execute方法
<action name="*Action" class="Jcuckoo.{1}Action"> <result name="input">/login.jsp</result> <result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result> </action>
上面没有出现method属性,故默认调用对应的execute方法
如果用户请求的URL为LoginAction.action,则调用Jcuckoo.LoginAction中的execute方法; 如果用户请求的URL为RegisterAction.action,则调用Jcuckoo.RegisterAction中的execute方法;
形式三:动态结果
<action name="crud_*" class="Jcuckoo.CrudAction" method="{1}"> <result name="input">/input.jsp</result> <result>/{1}.jsp</result> </action>
当处理结果是input时,会转到/input.jsp页面
2014年执业医师资格考试 医学综合笔试 临床执业医师 口腔执业医师 中医执业医师
当处理结果是success时,
如果crud_create.action,则会执行Jcuckoo.CrudAction中的create方法,并且跳转到/create.jsp; 如果crud_delete.action,则会执行Jcuckoo.CrudAction中的delete方法,并且跳转到/delete.jsp;
Struts2 Action下面的Method调用方法的更多相关文章
- struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法
struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法
- struts2.Action中的method属性配置
.Action中的method属性 在struts1.x中我们知道通过继承DispatchAction可以实现把多个Action进行统一操作,在struts2中实现action的统一操作也很简单.我们 ...
- 第三章Struts2 Action中动态方法调用、通配符的使用
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
- Struts2 Action中动态方法调用、通配符的使用
一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...
- 关于AOP无法切入同类调用方法的问题
一.前言 Spring AOP在使用过程中需要注意一些问题,也就是平时我们说的陷阱,这些陷阱的出现是由于Spring AOP的实现方式造成的.每一样技术都或多或少有它的局限性,很难称得上完美,只要掌握 ...
- phpcms 的实用相关接口,函数,调用方法
常用函数 , 打开include/global.func.php,下面存放一些公共函数view plaincopy to clipboardprint? strip_tags() 调用内容过滤html ...
- phpcms常用接口调用方法
常用函数 , 打开include/global.func.php,下面存放一些公共函数 view plaincopy to clipboardprint?function str_charset($i ...
- webservice的调用方法
一.WebService在cs后台程序中的调用 A.通过命名空间和类名直接调用 示例: WebService ws = new WebService(); string s = ws.HelloWor ...
- SOA 下实现分布式 调用 cxf+ webService +动态调用
近期项目间隙 自学了 webservice 一下 是我写的 一个demo 首先我们在web.xml 里配置如下 <servlet> <servlet-name>CXFS ...
随机推荐
- ssh远程执行命令
ssh -p $port $user@$p 'cmd' $port : ssh连接端口号 $user: ssh连接用户名 $ip:ssh连接的ip地址 cmd:远程服务器需要执行的操作 ssh -p ...
- PHP的一些开源项目网站
https://github.com/wenzhixin/bootstrap-table https://github.com/1000hz/bootstrap-validator
- (转)解决Mac OS X上PhpStorm不能输入中文
看到Netbeans上类似问题的解决办法: /Applications/netbeans/NetBeans 6.7.1/Content/Resource/netbeans/etc/netbeans.c ...
- 求System.arraycopy的用法
public class Shuzufuzhi { public static void main(String args[]) { int myArray[]={1,2,3,4,5,6}; in ...
- Struts2 简介
回顾Struts2的使用过程,网上搜的教程多多少少都会有点问题,重新记录下创建过程,方便查阅. 1.下载Struts2的jar包 下载地址:http://archive.apache.org/dist ...
- venus
The Venus system was a small timesharing system serving five or six users at a time:分时系统 The design ...
- 流媒体测试笔记记录之————解决问题video.js 播放m3u8格式的文件,根据官方的文档添加videojs-contrib-hls也不行的原因解决了
详细代码Github:https://github.com/Tinywan/PHPSharedLibrary/tree/master/Tpl/Html5/VideoJS 想播放hls协议的就是m3u8 ...
- HTML5扩展之微数据与丰富网页摘要
一.微数据是? 一个页面的内容,例如人物.事件或评论不仅要给用户看,还要让机器可识别.而目前机器智能程度有限,要让其知会特定内容含义,我们需要使用规定的标签.属性名以及特定用法等.举个简单例子,我们使 ...
- Compare接口
1.Comparable接口 此接口强行对实现它的每个类的对象进行整体排序.此排序被称为该类的自然排序 ,类的 compareTo 方法被称为它的自然比较方法 .实现此接口的对象列表(和数组)可以通过 ...
- Java 源码解析之局部变量检查
package com.tang; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream ...