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调用方法的更多相关文章

  1. struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法

    struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法

  2. struts2.Action中的method属性配置

    .Action中的method属性 在struts1.x中我们知道通过继承DispatchAction可以实现把多个Action进行统一操作,在struts2中实现action的统一操作也很简单.我们 ...

  3. 第三章Struts2 Action中动态方法调用、通配符的使用

    01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...

  4. Struts2 Action中动态方法调用、通配符的使用

    一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...

  5. 关于AOP无法切入同类调用方法的问题

    一.前言 Spring AOP在使用过程中需要注意一些问题,也就是平时我们说的陷阱,这些陷阱的出现是由于Spring AOP的实现方式造成的.每一样技术都或多或少有它的局限性,很难称得上完美,只要掌握 ...

  6. phpcms 的实用相关接口,函数,调用方法

    常用函数 , 打开include/global.func.php,下面存放一些公共函数view plaincopy to clipboardprint? strip_tags() 调用内容过滤html ...

  7. phpcms常用接口调用方法

    常用函数 , 打开include/global.func.php,下面存放一些公共函数 view plaincopy to clipboardprint?function str_charset($i ...

  8. webservice的调用方法

    一.WebService在cs后台程序中的调用 A.通过命名空间和类名直接调用 示例: WebService ws = new WebService(); string s = ws.HelloWor ...

  9. SOA 下实现分布式 调用 cxf+ webService +动态调用

    近期项目间隙 自学了  webservice   一下 是我写的  一个demo 首先我们在web.xml 里配置如下 <servlet> <servlet-name>CXFS ...

随机推荐

  1. CentOS 7.2.1511编译安装Nginx1.10.1+MySQL5.6.33+PHP5.6.26

    准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...

  2. UVA 11520 填充正方形

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. 3d游戏模型及地形提取及导航

    支持所有DirectX的游戏模型提取 有需要的可以直接联系我!QQ290387340

  4. Arduino 极速入门系列 - 光控灯(2) - 关于开关,上拉、下拉电阻那些事

    接上篇,这次继续讲解光控灯的另外两个组成部分 - 开关和光敏电阻,光控灯里面将会有自锁开关按钮和光敏电阻.这此主要给新玩电子的朋友解释一下开关按钮的做法. 开关按钮的引脚电平读取问题 - 新手专用 我 ...

  5. MySQL初始配置

    mysql初始密码在/var/log/mysqld.log中 ,搜索:temporary password #mysql -uroot -p 登录mysql MYSQL密码策略有3级(0,1,2)默认 ...

  6. 22.mongodb副本集集群

    软件版本64位:     $ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.0.tgz     mongo ...

  7. nancy中视图呈现 Html.Partial(RenderPage的替代品)

    在mvc中有RenderPage 用来呈现其他视图的内容,而在nancy中没有RenderPage.怎么办呢? mvc中RenderPage的替代品,就是 Html.Partial. 使用方式 @Ht ...

  8. SIGPIPE了解

    当未连接成功相机网络,在socket请求中 if (_session->prepareSession("192.168.1.1") != ICH_SUCCEED)    // ...

  9. mysql授权

    grant all privileges on testdb to userA@'%' 然而通过userA登录查看存储过程时仍然无权限查看,通过jdbc连接程序也报错, 之前mysql在windows ...

  10. [mobile开发碎碎念]手机页面上显示PDF文件

    demo:http://mozilla.github.io/pdf.js/web/viewer.html 项目地址:https://github.com/mozilla/pdf.js <scri ...