zoukankan      html  css  js  c++  java
  • Struts2 中result type属性说明

    首先看一下在struts-default.xml中对于result-type的定义:

    <result-types>
    <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
    <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
    <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
    <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
    <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
    <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
    <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
    <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
    <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
    <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
    </result-types>

    chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息.

    dispatcher:用来转向页面,通常处理JSP.

    freemaker:处理FreeMarker模板.

    httpheader:控制特殊HTTP行为的结果类型.

    redirect:重定向到一个URL,被跳转的页面中丢失传递的信息,如request.

    redirectAction:重定向到一个Action,跳转的页面中丢失传递的信息.

    stream:向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据.

    velocity:处理Velocity模板.

    xslt:处理XML/XLST模板.

    plainText:显示原始文件内容,例如文件源代码.


    重点说一下redirect和redirectAction的区别:

    (1)使用redirect需要后缀名,使用redirect-action可以不需要后缀名.

    (2)type="redirect"的值可以转到其它命名空间下的action,而redirect-action只能转到同一命名空下的action,因此它可以省略.do的后缀直接写action的名称.

     

    参考:

    http://blog.csdn.net/voyage_mh1987/article/details/5829163

    http://onlylove.iteye.com/blog/154844

     

  • 相关阅读:
    git 撤销更改的文件
    git基于某个分支创建分支
    nodejs 支付宝app支付
    windows提交代码到git仓库
    MongoError: Cannot update '__v' and '__v' at the same time,错误解决办法
    作业3.输入一个年份,判断是闰年还是平年
    作业2.判断一元二次方向根的情况
    求3个数中的最大数
    语句
    运算符
  • 原文地址:https://www.cnblogs.com/shihujiang/p/2543911.html
Copyright © 2011-2022 走看看