Struts 2 入门 二(Struts2 Action配置)

 

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 是重定向  客户端跳转

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值