Action继承了com.opensymphony.xwork2.ActionSupport。

  package com.candy.login;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {}

继承了ActionSupport后,可以在execute()里加入以下验证信息:

  addActionError(""); // Action错误提示
addFieldError("", ""); // 字段错误提示
addActionMessage(""); // 错误消息

就目前继承ActionSupport的作用有两个:
1、addActionError("")/addFieldError("","")/addActionMessage("")三个方法都是从这个类继承的,可以在自己的Action中使用。
2、我找到的ActionSupport的五个静态常量,也可以在自己的Action中的使用。同时,在struts.xml中<result>/main.jsp</result>和<result name="success">/main.jsp</result>的功能是一致的。

 public static final java.lang.String SUCCESS = "success";
public static final java.lang.String NONE = "none";
public static final java.lang.String ERROR = "error";
public static final java.lang.String INPUT = "input";
public static final java.lang.String LOGIN = "login";

同时,发下web.xml和struts.xml

web.xml:

 <?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

struts.xml:

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<!-- <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache
Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> -->
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
<package name="struts2" extends="struts-default" namespace="/">
<global-results>
<result name="errorPath" type="redirect">
/errorPage.jsp
</result>
</global-results>
<action name="LoginAction" class="com.candy.login.LoginAction">
<result name="error">index.jsp</result>
<result>/WEB-INF/main.jsp</result>
</action>
</package> <!-- 引用其他模块的Struts.xml配置文件 -->
<!-- <include file="testStruts.xml"/> --> <!-- Apache Struts2官方网站 -->
<!-- http://struts.apache.org/release/2.0.x/ -->
</struts>

SSH-Struts第一弹:ActionSupport类的更多相关文章

  1. struts 中继承ActionSupport类

    理论上Struts 2.0的Action无须实现任何接口或继承任何类型,但是,我们为了方便实现Action,大多数情况下都会继承 com.opensymphony.xwork2.ActionSuppo ...

  2. (一)、Struts第一天

    (一).Struts第一天 1. JavaWeb知识回顾 n 客户端编程 HTLM/CSS/JS n XML技术 会写XML * 基本语法 * DTD * Schema 会读XML * Dom4J读取 ...

  3. Spring Boot 第一弹,问候一下世界!!!

    持续原创输出,点击上方蓝字关注我吧 目录 前言 什么是Spring Boot? 如何搭建一个Spring Boot项目? 第一个程序 Hello World 依赖解读 什么是配置文件? 什么是启动类? ...

  4. 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog

    [源码下载] 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog 作者:webabcd 介绍背水一战 Windows 10 之 控 ...

  5. typecho流程原理和插件机制浅析(第一弹)

    typecho流程原理和插件机制浅析(第一弹) 兜兜 393 2014年03月28日 发布 推荐 5 推荐 收藏 24 收藏,3.5k 浏览 虽然新版本0.9在多次跳票后终于发布了,在漫长的等待里始终 ...

  6. Struts2实现Preparable接口和【struts2】继承ActionSupport类

    Struts2实现Preparable接口 实现preparable接口,实现public void prepare() throws Exception 方法.当你访问某问action指定方法之前, ...

  7. 我的长大app开发教程第一弹:Fragment布局

    在接下来的一段时间里我会发布一个相对连续的Android教程,这个教程会讲述我是如何从零开始开发“我的长大”这个Android应用. 在开始之前,我先来介绍一下“我的长大”:这是一个校园社交app,准 ...

  8. 【struts2】继承ActionSupport类

    在Struts2中,Action可以不实现任何特殊的接口或者继承特殊的类,仅仅是一个POJO(Plain Old Java Object,简单的Java对象)就可以:也可以实现Xwork2中的Acti ...

  9. struts2为什么action要继承actionSupport类

    我们为了方便实现Action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类, 并重载(Override)此类里的String execute()方法 ...

  10. Hadoop基础-MapReduce的工作原理第一弹

    Hadoop基础-MapReduce的工作原理第一弹 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在本篇博客中,我们将深入学习Hadoop中的MapReduce工作机制,这些知识 ...

随机推荐

  1. 匿名函数:Lambda表达式和匿名方法

    匿名函数一个"内联"语句或表达式,可在需要委托类型的任何地方使用.可以使用匿名函数来初始化命名委托,或传递命名委托(而不是命名委托类型)作为方法参数. 共有两种匿名函数: Lamb ...

  2. 半透明状态栏(适用于搜索等)CSS样式

    .search-{ -webkit-box-flex: ; -moz-box-flex:; text-align: left; font-size:14px; line-height:22px; he ...

  3. ubuntu下JDK的安装

    硬盘上有下载好的JDK,直接解压后配置profile环境变量就行 export JAVA_HOME=/usr/lib/jvm/java-8-oracle export JRE_HOME=${JAVA_ ...

  4. OpenGL Pixel Linked-List

    Keywords: opengl linked list http://on-demand.gputechconf.com/gtc/2014/presentations/S4385-order-ind ...

  5. FBX Transformation

    2010: http://download.autodesk.com/us/fbx/20102/FBX_SDK_Help/index.html?url=WS1a9193826455f5ff3913a1 ...

  6. QQ客服出现“企业QQ在线咨询无权限在当前场景使用!” 问题

    加入了QQ“多客服”功能 会出现这个问题 解决办法: 在平台http://wp.qq.com/ 上设置,只需两步骤 步骤一:在http://wp.qq.com/set.html 里,安全级别选项,选择 ...

  7. Web Pages - Efficient Paging Without The WebGrid

    Web Pages - Efficient Paging Without The WebGrid If you want to display your data over a number of p ...

  8. inline-block元素overflow:hidden对齐问题

    inline-block元素设置overflow:hidden后,其本身会上移 解决方法:在该元素或其父元素上设置vertical-align:bottom 原因解释:inline-block元素被设 ...

  9. uname是什么?

    uname= unix +name, 是指unix 这个操作系统的 名字, 包括 主机名, 内核版本 架构 平台名称等等

  10. php 关于时区 date gmdate date_default_timezone_set/get 终极答疑

    关于GMT和UTC时间? GMT+0800 Greenwich: [gri:nitf], 格林威治/格林尼治.是英国伦敦泰晤士河附近的一个小镇 Mean: adj. 自私的; n. 平均.. he i ...