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 ...
随机推荐
- JAVA中取余(%)规则和介绍
在java中%的含义为取余. java :a%b 数学公式a%b=a-(a/b)*b
- C#利用HttpWebRequest进行post请求的示例(HTTPS)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- 微信https请求工具类
工作中用到的微信https请求工具类. package com.gxgrh.wechat.tools; import com.gxgrh.wechat.wechatapi.service.System ...
- hdu 4585 Shaolin treap
Shaolin Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Problem ...
- Linux英文全称
su:Swith user 切换用户,切换到root用户cat: Concatenate 串联uname: Unix name 系统名称df: Disk free 空余硬盘du: Disk u ...
- Android单例线程池
package com.jredu.schooltong.manager; import java.util.concurrent.ExecutorService;import java.util.c ...
- ZigBee 安全探究
ZigBee 安全探究 0x02 ZigBee安全机制 (注:对于本节内容,可能在新版ZigBee协议标准中会有所变化,请以新版为准.) ZigBee主要提供有三个等级的安全模式: 1. 非安全模式: ...
- String转double或者float会有精度丢失的问题
float [] value=new float[5]; value[0]=Float.parseFloat(rs.getString(1)); value[1]=Float.parseFloat(r ...
- VS学习
7.9 今天打开老师给的俄罗斯方块的程序,硬是跑不出来.已经遇到了这几个问题 [1]在项目属性里面C++目录中修改头文件和库函数的绝对路径(基础知识刚学会) [2]errorC1083 SDKDDKe ...
- 锁相关知识 & mutex怎么实现的 & spinlock怎么用的 & 怎样避免死锁 & 内核同步机制 & 读写锁
spinlock在上一篇文章有提到:http://www.cnblogs.com/charlesblc/p/6254437.html 通过锁数据总线来实现. 而看了这篇文章说明:mutex内部也用到 ...