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 ...
随机推荐
- 用CSS制作伪标签云
performance testing stress testing conformance testing acceptane testing smoke testing regression te ...
- 学习git与github的二三事 (一)
前一段时间看到了一个参加机器人比赛的同学写的经验之谈,他提到了在比赛时,希望同学们学习一下git来管理代码,于是我就某度了一下,发现了廖雪峰老师的网站,受益匪浅,持续学习中,拜谢大神,顺便记录一下自己 ...
- 一次U盘拯救的经历
U盘拷资料,突然就弹出框框,复制终止了,然后U盘里面的只是编程可读的了. 倒是没有啥重要的资料,就是只有这一个U盘了,平时传资料都靠它,不能就这么垮了啊,于是就来了一次拯救行动. 一共有三个步骤 第一 ...
- Query Designer:公式冲突
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- JS事件模型小结
三种事件模型:原始事件模型(DOM0),DOM2事件模型,IE事件模型: 不同点: 事件程序的注册(给HTML元素所对应的JS对象绑定事件) 事件传播的过程 事件模型的注册: 一.原始事件模型(没有兼 ...
- 非root用户安装软件
下面简要说一下Linux下非root用户安装软件的一般流程: 1. 获取源代码,一般是wget方式,ubuntu可以使用apt-get source来获取源代码. 2. 解压源代码,一般使用tar - ...
- 解决iphone5s,iphone6不能使用luajit及luac的问题
做手游有小段时间了,感觉坤哥给这么多的机会.一直都比较忙项目的事,比较没时间去写点东西做点记录.想想还是写点开发问题记录比较好,可以很简短,也可以很有用. 我们项目采用的cocos2d-x的引擎,之前 ...
- A little bit about Handlers in JAX-WS
by Rama Pulavarthi Handlers are message interceptors that can be easily plugged in to the JAX-WS run ...
- Spring AOP中pointcut expression表达式解析
Pointcut 是指那些方法需要被执行"AOP",是由"Pointcut Expression"来描述的. Pointcut可以有下列方式来定义或者通过&am ...
- js跨域_jsonP
$.ajax("url", type:"get", dataType:"jsonp", jsonp:"callback" ...