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. WinForm------TreeList属性介绍

    转载: http://blog.csdn.net/fwj380891124/article/details/6888077 treeList1.LookAndFeel.UseWindowsXPThem ...

  2. spark 读取 elasticsearch数据

    –master spark://10.8.2.100:7077 –jars /usr/local/spark-1.5.2/lib/elasticsearch-hadoop-2.1.1.jar

  3. sphinx :undefined reference to `libiconv' 报错解决办法

    sphinx :undefined reference to `libiconv' 报错解决办法   2013-11-30 21:45:39 安装sphinx时不停报错...郁闷在make时报错,错误 ...

  4. scrapy2_初窥Scrapy

    递归知识:oop,xpath,jsp,items,pipline等专业网络知识,初级水平并不是很scrapy,可以从简单模块自己写. 初窥Scrapy Scrapy是一个为了爬取网站数据,提取结构性数 ...

  5. eclipse安装springsource-tool-suite

    到http://spring.io/tools/sts/all找到安装的eclipse对应的springsource-tool-suite版本,复制下载的网址 然后在eclipse的install n ...

  6. time模块

    In [1]: import time In [2]: import datetime In [3]: date_time = datetime.datetime.now() In [4]: prin ...

  7. BaKoMa Tex Word 的使用

    数学论文编排软件,付费,但是可以这么处理,安装好后不要马上打开,进入影子系统的时候再运行它,这样每次都是全新的, 优势是 WYSIWYG,所见即所得, 中文输入, \documentclass{art ...

  8. Mysql 与 Python socket

    py1.py # -*- coding: utf-8 -*- import sqlalchemy import tushare import pandas import socket import s ...

  9. Unreal模型文件调查

    http://en.wikipedia.org/wiki/UE_Viewer http://www.gildor.org/en/projects/umodel http://wiki.beyondun ...

  10. MYSQL 免安装版(windows 7/64)

    本文介绍在本地安装MYSQL数据库,免安装版相关配置 一.下载 mysql下载地址1:http://dev.mysql.com/downloads/mysql/ 二.解压MySQL压缩包 将已下载的M ...