Struts 2 入门 二(Struts2 Action配置)
2013-05-25 00:39
381 查看
Struts 2 入门 二(Struts2 Action配置)
<package name="default" namespace="/" extends="struts-default"> <action name="index"> <result type="redirectAction"> <param name="actionName">HelloWorld</param> <param name="namespace">/example</param> </result> </action> </package>
首先要先定义 一个 包 必须继承 struts-default
action 常用属性:
name: 必须
class: 不是必须 默认是ActionSupport
method: 不是必须 默认是 execute
Result 常用属性:
name: 不是必须 默认是 SUCCESS
type:不是必须 默认是 dispatcher
Struts 源码
If the class attribute in an action mapping is left blank, the com.opensymphony.xwork2.ActionSupport class is used as a default. 如果类属性在一个操作映射为空白,com.opensymphony.xwork2。ActionSupport类作为一个默认的。 Another common workflow stategy is to first render a page using an alternate method, likeinput and then have it submit back to the default execute method. 默认方法 execute Setting a default Result Type (设置一个默认的结果类型) <result-types> <result-type name="dispatcher" default="true" class="org.apache.struts2.dispatcher.ServletDispatcherResult" /> </result-types> Likewise if the name attribute is not specified, the framework will give it the name "success". (同样,如果没有指定名称属性,该框架将给它命名为“success”。)
dispatcher和Forward 都是 请求转发 也是 服务器端跳转
redirect 是重定向 客户端跳转
相关文章推荐
- Struts2中struts.xml的Action配置详解
- 【Struts2学习笔记】struts2.5使用通配符配置action跳转
- Struts2学习笔记之struts.xml配置常量和Action处理流程
- struts2 入门2:struts配置相关与拦截器
- Struts2之两个Action传值和不传值的struts.xml文件配置
- 在Struts2 中 struts.xml的Action配置详解
- struts2——(3)(①struts配置文件struts.xml三个元素package,action,result详解)
- Struts2中struts.xml的Action配置详解
- struts2之Action配置的各项默认值、result配置的各种试图转发类型及为应用指定多个struts配置文件
- struts2 (一) web.xml/struts.xml/Action 配置
- struts2的配置之could not find action or result 问题的解决方法(struts.xml文件路径)
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- struts2 两个action方法的跳转 struts.xml怎么配置
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- JAVAWEB开发之Struts2详解(一)——Struts2框架介绍与快速入门、流程分析与工具配置以及Struts2的配置以及Action和Result的详细使用
- Struts2学习笔记之与struts.xml配置和Action有关的属性
- Struts2中struts.xml的Action配置详解
- [转]Struts2中struts.xml的Action配置详解
- Struts2中struts.xml的Action配置详解(一)===》 struts2.0中struts.xml配置文件详解 (二)==》Struts2_struts.xml配置及例程三
- Struts2中struts.xml的Action配置详解