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

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";
}
}
主站蜘蛛池模板: 宁河县| 凉城县| 苗栗市| 洱源县| 高阳县| 旅游| 大兴区| 泸西县| 苍溪县| 景泰县| 九龙县| 信丰县| 长岭县| 扶余县| 康定县| 林西县| 青海省| 马山县| 朝阳县| 北安市| 丹棱县| 新津县| 历史| 安徽省| 玉树县| 永吉县| 介休市| 永康市| 安平县| 通辽市| 腾冲县| 遂平县| 平山县| 江永县| 双鸭山市| 昌平区| 获嘉县| 耿马| 泉州市| 兴安盟| 三门峡市|