struts2笔记08-初识ActionSupport

1、配置一个最简单的action

<action name="simple-action">
	<result>/simple.jsp</result>
</action>

 没有class, 没有method,result也没有name属性,但是可以访问成功!肯定是struts2背后偷偷帮我们干了些什么。

2、struts-default.xml

/struts2-core-2.3.28.jar/struts-default.xml

<default-class-ref class="com.opensymphony.xwork2.ActionSupport" />

这里配置了一个默认class,就是ActionSupport.

3、ActionSupport类

   查看源代码

public class ActionSupport implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable

  查看Action接口

package com.opensymphony.xwork2;

public interface Action {

    public static final String SUCCESS = "success";
  
    public static final String NONE = "none";

    public static final String ERROR = "error";

    public static final String INPUT = "input";
 
    public static final String LOGIN = "login";

    public String execute() throws Exception;
}

 这个Action接口,简单至极,再看ActionSupport实现的execute源码

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

  

struts2默认就给我们做了这些事,如果我们配置了一个action,没有配置class,就用它了,默认method为execute,result默认name为success. 

转载于:https://www.cnblogs.com/sdnu/p/5352783.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值