struts2_Action的三种实现方式

1.普通java类

package com.ahd.action;

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

注意事项,必须要有公有的返回值为字符串的execute方法,返回值可以参考Action接口

2.继承ActionSupport类

package com.ahd.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport{
    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        return "SUCCESS";
    }
}

 

3.实现Action接口

package com.ahd.action;

import com.opensymphony.xwork2.Action;

public class HelloAction implements Action{
    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        return Action.SUCCESS;
    }
}

 

posted @ 2018-10-24 11:27  爱华顿g  阅读(256)  评论(0编辑  收藏  举报