官术网_书友最值得收藏!

Implementing the commands

Here, we have AbstractCommand, which is an abstract class with one execute method. This is the abstract command, and the execute method is implemented on the subclasses:

public abstract class AbstractCommand {

public abstract String execute();
}

In the following code snippet, we have the subclass HomeCommand, which is the implementation of AbstractCommand. The method execute() returns the path to the home page (/home.jsp):


public class HomeCommand extends AbstractCommand {
@Override
public String execute() {
return "/home.jsp";
}
}

Here, we have the LoginCommand subclass, which is the implementation of AbstractCommand. The execute() method returns the path to the login page (/login.jsp):


public class LoginCommand extends AbstractCommand {
@Override
public String execute() {
return "/login.jsp";
}
}
主站蜘蛛池模板: 永济市| 安阳市| 元江| 怀宁县| 兖州市| 通河县| 浦城县| 望都县| 兴安县| 八宿县| 同心县| 巩义市| 崇明县| 张家口市| 白银市| 南汇区| 扎赉特旗| 佛教| 扶沟县| 西宁市| 太原市| 交口县| 获嘉县| 东平县| 东乡县| 平度市| 株洲市| 云安县| 彭山县| 嘉定区| 太和县| 鸡西市| 义乌市| 虹口区| 巴青县| 堆龙德庆县| 敦化市| 长海县| 稷山县| 乃东县| 高青县|