struts.xml(一)的<action-mappings>标签详解
来源:互联网 发布:同济大学软件研究生 编辑:程序博客网 时间:2024/04/30 18:07
action-mappings
该元素用于将Action元素定义到ActionServlet类中,它含有0到多个<action/>元素,其格式如下:
<action-mappings>
<action path="Action请求的相对路径,与页面<html:form>的Action属性值一致"
type="该Action的对应类的全路径"
name="该Action绑定的FormBean,与<form-bean >的Name属性值一致"
<forward name="与Action类中mapping.findForward("mapname")返回的mapname值一致" path="页面跳转的相对路径"/>
</action>
</action-mappings>
每个action子元素可包含一个或多个forward子元素。除了path、type和name属性外,action还具有如下属性:
lscope:指定ActionForm Bean的作用域(session和request),缺省为session。(可选);
linput:当Bean发生错误时返回的路径,在validate验证框架中错误显示的页面(可选);
lclassname:指定一个调用这个Action类的ActionMapping类的全名。缺省用org.apache.struts.action.ActionMapping(可选);
linclude:如果没有forward的时候,它起forward的作用(可选);
lvalidate:若为true,则会调用ActionForm的validate()方法或调用validate验证,否则不调用,缺省为true(可选)。
forward属性也是可选的。
action元素定义举例如下:
Example1.
Eg2. 有input属性的例子:
- <P><action-mappings></P><P> <action
- path="/userAction"
- type="com.amigo.struts.action.UserAction"
- name="UserForm"
- scope="request"
- validate = "false"
- parameter="method" >
- <forward name="error" path="/user/error.jsp" />
- <forward name="success" path="/user/success.jsp"/>
- <forward name="add" path="/user/addUser.jsp"/>
- <forward name="update" path="/user/updateUser.jsp"/>
- <forward name="list" path="/user/userList.jsp"/>
- </action>
- </action-mappings></P>
Eg3. 仅有JSP的action元素:
- <action-mappings>
- <action path="/calcAction"
- type="com.amigo.struts.action.CalcAction"
- name="CalcForm"
- scope="request"
- validate="true"
- input="/index.jsp">
- <forward name="success" path="/success.jsp"/>
- <forward name="error" path="/error.jsp"/>
- </action>
- </action-mappings>
首先,ActionServlet接到请求后调用ForwardAction的execute()方法,execute()根据配置的parameter属性值来forward到那个URI。
- <action path="/menu"
- parameter="/default.jsp"
- type="org.apache.struts.actions.ForwardAction" />
这样做的效果是:没有任何form被实例化,比较现实的情形可能是form在request更高级别的范围中定义;或者这个action被用作在应用程序编译好后充当系统参数,只需要更改这个配置文件而不需要重新编译系统。
- struts.xml(一)的<action-mappings>标签详解
- Struts-config.xml配置文件《action-mappings》元素的详解
- Struts-config.xml配置文件《action-mappings》元素的详解
- Struts-config.xml配置文件《action-mappings》元素的详解
- Struts1的struts-config.xml中action-mappings的parameter 属性详解
- struts-1.3.10中的<action-mappings> <action>标签中<set-property>的用法
- struts之action mappings
- Struts-config.xml 配置 动态FormBean与action-mappings元素
- struts.xml中action标签的学习
- <action-mappings > 属性详解
- Struts标签<s:action>的使用详解
- struts.xml中Action的配置详解
- Struts2的配置 struts.xml Action详解
- struts.xml(二)<action>使用详解
- struts框架中struts.xml中action标签中result标签的两个常用属性
- Struts2中struts.xml的Action配置详解(一)===》 struts2.0中struts.xml配置文件详解 (二)==》Struts2_struts.xml配置及例程三
- struts.xml中的include标签和package标签以及action标签的name属性
- struts-struts标签的使用(一)
- 先做个小计划吧
- iOS 服务器文件有修改才进行下载
- iOS录音,调用麦克风话筒
- C#入门9.13——类的多态
- PHP学习:函数
- struts.xml(一)的<action-mappings>标签详解
- Fragment异常:Binary XML file line XXX: Error inflating class fragment
- 看到一张比较好的关于特征工程的图
- CodeForces-710A. King Moves
- 计算机网络-传输层
- android开发艺术探索(四)
- 检测App的内存占用和泄漏
- java 正则表达式使用
- leancloud对图片处理