博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
global-results
阅读量:4331 次
发布时间:2019-06-06

本文共 1817 字,大约阅读时间需要 6 分钟。

有很多时候一个<result>可供很多<action>使用,这时可以使用<global-results>标签来定义全局的<result>。

定义在<action>元素里面的<result>我们可以称之为局部<result>,除此之外我们还可以定义全局的<result>,这些全局的<result>会被多个<action>所共享。框架会首先寻找嵌套在<action>元素中的<result>,如果没有匹配的就去全局<result>中寻找。

      执行顺序:当一个Action返回的String没有相应的<result>与之对应,Struts2就会查找全局的<result>。

      <global-results>

              <result name="error">/Error.jsp</result>   <!--   Action.ERROR -->

    <result name="invalid.token">/Error.jsp</result>

    <result name="login" type="redirectAction">Logon!input</result>

  </global-results>

其中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" />             <!-- Deprecated name form scheduled for removal in Struts 2.1.0. The camelCase versions are preferred. See ww-1707 -->             <result-type name="redirect-action" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>             <result-type name="plaintext" class="org.apache.struts2.dispatcher.PlainTextResult" />         </result-types>

转载于:https://www.cnblogs.com/yaowen/archive/2013/02/21/2920686.html

你可能感兴趣的文章
万方数据知识平台 TFHpple +Xpath解析
查看>>
Hive实现oracle的Minus函数
查看>>
秒杀多线程第四篇 一个经典的多线程同步问题
查看>>
RocketMQ配置
查看>>
vs code调试console程序报错--preLaunchTask“build”
查看>>
蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
查看>>
端口号大全
查看>>
机器学习基石笔记2——在何时可以使用机器学习(2)
查看>>
POJ 3740 Easy Finding (DLX模板)
查看>>
MySQL 处理重复数据
查看>>
关于typedef的用法总结(转)
查看>>
【strtok()】——分割字符串
查看>>
Linux下安装rabbitmq
查看>>
曹德旺
查看>>
【转】判断点在多边形内(matlab)
查看>>
java基础之集合:List Set Map的概述以及使用场景
查看>>
Python 线程 进程 协程
查看>>
iOS语言中的KVO机制
查看>>
excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法
查看>>
响应式web设计之CSS3 Media Queries
查看>>