Action的3种实现方式

    xiaoxiao2021-08-27  83

    做笔记

    1. 定义一个pojo类

    好处:定义一个普通的java类即可 不具有侵入性

    public class helloAction { public String execute() { System.out.println("ok ok"); return "success"; } }

    2. 实现action接口

    好处:使得我们编写的代码更加规范

    public class hello1action implements Action{ public String execute() throws Exception { System.out.println("ok 2 ok"); return SUCCESS; } }

    3. 继承Actionsupport 类

    好处:可以继承一些Actionsupport实现的功能;如验证

    public class hello2action extends ActionSupport{ public String execute() throws Exception { System.out.println("ok 3 ok"); return SUCCESS; } }
    转载请注明原文地址: https://ju.6miu.com/read-677220.html

    最新回复(0)