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

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";
}
}
主站蜘蛛池模板: 新蔡县| 北票市| 横山县| 平武县| 象州县| 扶绥县| 高淳县| 平乡县| 江油市| 庄河市| 久治县| 绍兴市| 天全县| 淮安市| 西昌市| 静宁县| 义马市| 灯塔市| 黔西县| 镇沅| 司法| 滁州市| 泌阳县| 麻城市| 茶陵县| 施秉县| 外汇| 肇东市| 沂南县| 高安市| 铜梁县| 马边| 中西区| 轮台县| 宁陕县| 卢湾区| 辽源市| 清水县| 郧西县| 沙坪坝区| 贞丰县|