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

二.五个常量的介绍:

a: SUCCESS

  public static final String SUCCESS = "success";

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

   具体用法:

1.action类中:

 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视图。

上面就是简单的描述。

                                                                                                                                                                                                                                                                                                                      

Struts2中五个重要的常量的更多相关文章

  1. 十五、struts2中的拦截器(框架功能核心)

    十五.struts2中的拦截器(框架功能核心) 1.过滤器VS拦截器 功能是一回事. 过滤器是Servlet规范中的技术,可以对请求和响应进行过滤. 拦截器是Struts2框架中的技术,实现AOP(面 ...

  2. struts2中的常量

    struts2中的常量: 在:struts2-core-2.1.8.1\org\apache\struts2\default.properties 文件里 <!-- 配制i18n国际化--> ...

  3. struts2中的constant常量配置

    struts2中的constant配置详解 本文主要讲解一下struts2中的constant常量配置,内容主要来自于互联网的整理.<?xml version="1.0" e ...

  4. 简单理解Struts2中拦截器与过滤器的区别及执行顺序

    简单理解Struts2中拦截器与过滤器的区别及执行顺序 当接收到一个httprequest , a) 当外部的httpservletrequest到来时 b) 初始到了servlet容器 传递给一个标 ...

  5. struts2中如何使用主题theme

    一.什么是主题? 主题就是一种风格化标签,能够让所有UI标签能够产生同样的视觉效果而归集到一起的一组模板,即风格相近的模板被打包为一个主题 二.struts2提供的主题有哪些呢?struts2中如何修 ...

  6. struts2中struts.xml配置文件详解【未整理】

    1.    深入Struts2的配置文件 本部分主要介绍struts.xml的常用配置. 1.1.    包配置: Struts2框架中核心组件就是Action.拦截器等,Struts2框架使用包来管 ...

  7. Struts2中基于Annotation的细粒度权限控制

    Struts2中基于Annotation的细粒度权限控制 2009-10-19 14:25:53|  分类: Struts2 |  标签: |字号大中小 订阅     权限控制是保护系统安全运行很重要 ...

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

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

  9. struts2中constant参数设置

    序号 方法 说明 1 <constant name="struts.i18n.encoding" value="UTF-8"/> 指定web应用默认 ...

随机推荐

  1. 利用face_recognition库裁取人脸

    from PIL import Image import face_recognition # Load the jpg file into a numpy array image = face_re ...

  2. ASP.NET Core实现 随处可见的基本身份认证

    概览 在HTTP中,基本认证(Basic access authentication,简称BA认证)是一种用来允许网页浏览器或其他客户端程序在请求资源时提供用户名和口令形式的身份凭证的一种登录验证方式 ...

  3. HWPushDemo【华为推送集成,基于2.6.1.301版本】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 这个Demo只是记录华为推送的集成,不能运行. 另外,因为可能用到存储权限,所以还需要搭配运行时权限申请功能. 使用步骤 一.项目组 ...

  4. javascript入门篇(五)

    将日期转换为数字 全局方法 Number() 可将日期转换为数字 d = new Date(); Number(d)          // 返回 1404568027739 日期方法 getTime ...

  5. traefik 结合 docker-compose 的快速安装及使用

    traefik 介绍 traefik 是一个为了让部署微服务更加便捷而诞生的现代HTTP反向代理.负载均衡工具. 它支持多种后台 (Docker, Swarm, Kubernetes, Maratho ...

  6. DateUtil日期工具类

    目录 (1)需要导入的包 (2)DateUtil类 (1)需要导入的包 主要用于Strings.isNullOrEmpty(date) <!--string处理类--> <depen ...

  7. 20170319 - pycurl 提示 libcurl link-time version is older than compile-time version

    使用 conda update anaconda 升级后,运行程序得到如下提示: ImportError: pycurl: libcurl link-time version (7.45.0) is ...

  8. MySQL数据库优化方案

    优化索引.SQL语句.分析慢查询: 设计数据表的时候,严格根据数据库的设计范式来设计数据库表: 使用缓存,把经常访问的又不经常更改的数据放到缓存中,能减少磁盘I/O: 优化硬盘,使用SSD,使用磁盘队 ...

  9. 两篇文章带你走入.NET Core 世界:CentOS+Kestrel+Ngnix 虚拟机先走一遍(一)

    背景: 上一篇:ASP.Net Core on Linux (CentOS7)共享第三方依赖库部署 已经交待了背景,这篇就省下背景了. 折腾的过程分两步: 第一步是:本机跑虚拟机部署试一下: 第二步是 ...

  10. window下编译jcef

    自行编译jcef过程中遇到了一些问题,现在记录如下. 参考的主要文章是jcef的官方介绍: https://bitbucket.org/chromiumembedded/java-cef/wiki/B ...