一.五个常量的位置:位于xwork核心包下的Action字节码文件里

二.五个常量的介绍:

a: SUCCESS

    1  public static final String SUCCESS = "success";

       英文注释: The action execution was successful. Show result  view to the end user.      action执行成功,会返回一个结果视图给用户  。

   具体用法:

1.action类中:

1 public String execute() throws Exception {
2     return SUCCESS;
3 }

struts.xml文件:result标签默认就是success,所以可以省略,这里面默认的name="success",底层会自动帮你找寻返回值为success,并为其跳转到对应的视图界面

<result type="redirect">item.jsp</result>

  

b:  NONE

public static final String NONE = "none";

  英文解释:The action execution was successful but do not show a view. This is useful for actions that are handling the view in another fashion like redirect.

   action执行是成功的,但是不会显示界面(视图),这对于以另一种重定向方式处理视图是有用的。简单说就是不让跳转到其他界面

具体用法:

public String execute() throws Exception {return NONE;
}

c:   ERROR 

 public static final String ERROR = "error";

  英文解释:The action execution was a failure.Show an error view, possibly asking the user to retry entering data.

  action执行失败了,跳转显示一个错误视图,可能请求用户再次输入相关数据。也就是说,当anction返回结果fail或者其他失败,会帮你跳转到错误信息对于的视图

具体用法:

//action类:public String execute() throws Exception {//条件代码return ERROR;
}

//struts.xml
<result name="error" type="redirect">item.jsp</result>

d: LOGIN

 public static final String LOGIN = "login";

  英文解释:The action could not execute, since the user most was not logged in. The login view should be shown.

  这个anction不能执行,由于用户没有登录 ,该登录视图可能会被显示。也就是说登录出错页面跳转

     

//action类:
public String execute() throws Exception {//条件代码return LOGIN;
}//struts.xml
<result name="login" type="redirect">login.jsp</result>

  e:   INPUT ***

 public static final String LOGIN = "input";

  英文:The action execution require more input in order to succeed.This result is typically used if a form handling action has been executed so as to provide defaults for a form. Theform associated with the handler should beshown to the end user.<p/>This result is also used if the given input params are invalid, meaning the user  should try providing input again.

这个action为了成功需要多次输入,如果一个表单表单处理action操作被执行,便会为表单提供默认表单,通常会使用此结果。这个表单会显示给最终用户,这个结果也被用来用户输入无效,这意味着用户需要在输入一遍

上面五个变量其中除了input,其他都可以使用自定义的,只有input不能改,input视图在某些拦截器中使用,如数据校验,类型转化等等都可能出现错误,这些错误在struts2中专门放在数据存储区域的错误信息区域,struts2再走到最后一个workflow拦截器种会检查错误区域是否有错误信息,如果有,跳转到input视图。

上面就是简单的描述。

                                                                                                                                                                                                                                                                                                                      

转载于:https://www.cnblogs.com/ends-earth/p/10701772.html

Struts2中五个重要的常量相关推荐

  1. Action中五个常量解释,(success,error,input,login,none)

    Action中五个常量解释,(success,error,input,login,none) 英文注释 中文释义 staticString ERROR The actionexecution was ...

  2. 二十四、Struts2中的UI标签

    二十四.Struts2中的UI标签 Struts2中UI标签的优势: 数据回显 页面布局和排版(Freemark),struts2提供了一些常用的排版(主题:xhtml默认 simple ajax) ...

  3. WEB Struts2 中OGNL的用法

    2019独角兽企业重金招聘Python工程师标准>>> User对象属性获取 如User中有username和password字段 获取username属性<s:propert ...

  4. 在Struts2中使用ValueStack、ActionContext、ServletContext、request、session等

    目录(?) [-] ValueStack 如何得到值栈: 如何将对象存入值栈: 让值栈执行表达式来获得值: 在JSP中跳过栈顶元素直接访问第二层: 在JSP中访问值栈对象本身(而不是它们的属性) Ac ...

  5. Struts2中的OGNL表达式

    基础知识(三) Struts2中的OGNL表达式 浅析值栈 ValueStack对象相当于一个栈,它贯穿整个Action的生命周期,每个Action类的对象实例都会拥有一个ValueStack对象 当 ...

  6. Struts2中的值栈

    一 什么是值栈 值栈: struts2中提供的一种类似于域对象的工具, 用于struts2中的存值和取值. 每次访问Action的时候, 都会创建一个action对象, 而每个action对象中都存在 ...

  7. Struts2中XXX.Action类中方法的访问(三种方式)

    第一种:使用action标签的method属性(常规方法) Action类: package cn.tedu.web;import org.springframework.context.annota ...

  8. JFreeChart在Struts2中实现3D折线图统计

    在Struts2中,用JFreeChart实现3D折线图统计 前段时间学习了一下JFreeChart,现在来整理一下自己所作的实例. 下面分别用两种方式来实现: 一种是以java应用程序的方式,一种是 ...

  9. JFreeChart在Struts2中实现饼状图统计

    在Struts2中,用JFreeChart实现饼状图统计 前段时间学习了一下JFreeChart,现在来整理一下自己所作的实例. 下面分别用两种方式来实现: 一种是以java应用程序的方式,一种是以w ...

最新文章

  1. mysql通用分页_MySQL海量数据的通用存储过程分页代码
  2. 使用Flash彻底美化你的程序
  3. Win11 不支持移动任务栏位置;苹果将推出更大尺寸的 iPad Pro;iOS 15 更新 Beta2 版本|极客头条...
  4. Axure教程-新手入门基础(小白强烈推荐!!!)
  5. Flash CS4 Professional 10.0.2简体中文版下载地址
  6. Shell入门之管道
  7. mysql recordcount 1_移植到 MySQL-对 MYSQL 数据库使用 ASP Recordcount 的问题
  8. Automatic detection and segmentation of optic disc and fovea in retinal images
  9. 路由器当交换机用,应该怎样配置?
  10. 用pip install pqi时报错:parse() got an unexpected keyword argument 'transport_encoding'
  11. find:paths must precede expression问题及解决
  12. 记一次笔试遇到leetcode原题却没a出来的经历
  13. UiPath与按键精灵区别
  14. 截图工具因为计算机无法使用,win7系统电脑自带截图工具不能用失灵了的解决方法...
  15. 黑莓Z30评测–黑莓10中的均衡之作
  16. 02 - OAI(OpenAirInterface)核心网搭建过程 - 研0
  17. 【摸鱼系列】如何用Python做一个有趣的Loading彩蛋游戏~
  18. Twitter登录Callback URL not approved for this client application错误记录
  19. 【ML】贝叶斯分类和朴素贝叶斯分类
  20. 计算机辅助绘图中测距在哪,我CAD怎么测量距离不行

热门文章

  1. swift开源项目精选
  2. 如何运用UIControl自定义iOS中的控件
  3. MyEclipse运行tomcat提示严重错误 严重: Error starting endpoint java.lang.Exception: Socket
  4. 如何实施好基于MOSS的企业搜索项目(上)
  5. Uuntu 20.04 install OpenLDAP
  6. Tesla超越谷歌无人驾驶汽车雄心的背后,是以色列公司Mobileye
  7. 基于Apache Spark的机器学习及神经网络算法和应用
  8. 服务器与浏览器数据传输过程中编码问题
  9. VS集成opencv编译C++项目遇到的问题
  10. cisco 双ISP线路接入 链路自动切换方案