原文地址:http://blog.csdn.net/wfcaven/article/details/5937557

default.properties

在Struts 2的核心jar包-struts2-core中,有一个default.properties的默认配置文件。里面配置了一些全局的信息,比如:

struts.enable.DynamicMethodInvocation = true,-动态方法调用,为true时,就可以在struts.xml配置“*”的通配符,来调用action里的方法(下面介绍)

struts.action.extension=action,-action 的后缀名,可以改成.to、.html等等

还有很多,但那个default.properties是不能被更改的。如需要更改里面的配置信息,可以在src根目录下建一个 struts.properties的配置文件,然后重写所要更改的配置信息。

Wildcards通配符

通配符有点类似于变量,但这里的变量是用“*”表示,看看一个例子

<action name="login_*" method="{1}"
class="com.zhang.action.LoginAction">
<result name="success">/pages/success.jsp</result>
<result name="error">/pages/error.jsp</result>
</action>

这里在action的name中通配了一个login_*,它对应映射的是method属性。如果在客户端发生一个这样的请 求:login_init.action、login_show.action等,这时服务器就会自动调用这个action中的init()方法或 show()方法。这里的method="{1}"代表是第一个“*”,如果有多个星号,就要根据顺序来通配{1},{2},{3}....

在如下面多个星号的配置:

<action name=”*/*” method=”{2}”  
class=”com.zhang.action.{1}Action”> 
<result name=”success”>/pages/success.jsp</result> 
<result name=”error”>/pages/error.jsp</result> 
</action>

其中第一个“*”映射到具体的某个action类,第二个“*”映射到该类的方法。不过这里要注意的name=”*/*",是相当于客户端要发送如 “Login/init.action”,在地址栏里就变成了/struts/Login/init.action,那服务器到底是会认 /init.action还是/Login/init.action呢。其实服务器默认还是/init.action,如果要使带"/"的action生 效,需要把default.properties中的

struts.enable.SlashesInActionNames = false改为true就可以,其实这样做还挺麻烦的,只要把name写 成"*_*"就不存在斜杠问题了

struts.enable.DynamicMethodInvocation = true 动态方法调用(转)的更多相关文章

  1. struts.enable.DynamicMethodInvocation = true 动态方法调用

    default.properties 在Struts 2的核心jar包-struts2-core中,有一个default.properties的默认配置文件.里面配置了一些全局的信息,比如: stru ...

  2. Struts2-整理笔记(二)常量配置、动态方法调用、Action类详解

    1.修改struts2常量配置(3种) 第一种 在str/struts.xml中添加constant标签 <struts> <!-- 如果使用使用动态方法调用和include冲突 - ...

  3. struts2DMI(动态方法调用)

    DMI(Dynamic Method Invoke)即动态,是strus2的一个特性,我们知道,在最开始学习strus2时,往往一个action中只有一个excute方法,比如说add,delete, ...

  4. struts2的动态方法调用(DMI)和通配符映射

    动态方法调用   1.Struts2默认关闭DMI功能,需要使用需要手动打开,配置常量 struts.enable.DynamicMethodInvocation = true 2.使用“!”方法,即 ...

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

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

  6. Struts2 动态方法调用

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

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

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

  8. Struts(八):动态方法调用

    动态方法调用:通过url动态调用action中的方法. 默认情况下,Struts的动态方法调用处于禁用状态. 测试定义一个action类: package com.dx.actions; public ...

  9. Struts 2之动态方法调用,不会的赶紧来

    学习Struts2框架以来为了减少Action 的数量,我们可以使用动态方法进行处理. 动态方法调用(Dynamic Method Invocation,DMI)是指表单元素的Action并不是直接等 ...

随机推荐

  1. Java初试

    另外在Java语言的代码内部书写文件路径时,需要注意大小写,大小写需要保持一致,路径中的文件夹名称区分大小写.由于’\’是Java语言中的特殊字符,所以在代码内部书写文件路径时,例如代表“c:\tes ...

  2. Day11 线程、进程、协程

    创建线程第一种:import threadingdef f1(arg): print(arg) t = threading.Thread(target=f1, args=(123,))#t.start ...

  3. How do I solve the error: An error was encountered while running (Domain = LaunchServicesError, Code = 0) ?

    How do I solve the error: An error was encountered while running (Domain = LaunchServicesError, Code ...

  4. block 数组排序

    #import <Foundation/Foundation.h> //定义⼀一个block,返回值为BOOL,有两个NSString参数.实现:判 //断字符串是否相等. BOOL (^ ...

  5. CVE-2015-1635,MS15-034 漏洞测试

    HTTP.sys远程执行代码漏洞(CVE-2015-1635,MS15-034) 远程执行代码漏洞存在于 HTTP 协议堆栈 (HTTP.sys) 中,当 HTTP.sys 未正确分析经特殊设计的 H ...

  6. A Statistical View of Deep Learning (I): Recursive GLMs

    A Statistical View of Deep Learning (I): Recursive GLMs Deep learningand the use of deep neural netw ...

  7. C51 I2C接口驱动,IO口模拟I2C(主+从)

    Master.asm ;/*------------------------------------------------------------------*/ ;/* --- STC MCU I ...

  8. 【Animations】

    这个比较高端了!CSS3动画帧数科学计算法 基于css的3d和动画 基于css的3d和动画(2) 如何使用JavaScript控制CSS Animations(动画)和Transitions(过渡) ...

  9. WPF之插件开发

    一:解决方案管理器截图 效果图: 二:简单功能说明 IMsg定义了一个接口,MYPlugin1实现接口功能,”插件式开发“实现程序运行时再调用非本身引用的dll文件,调用该dll的方法实现功能 三:I ...

  10. HDOJ(HDU) 2143 box(简单的多次判断-用的卫条件)

    Problem Description One day, winnie received a box and a letter. In the letter, there are three inte ...