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

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";
}
}
主站蜘蛛池模板: 石河子市| 灵璧县| 饶平县| 宁德市| 盘山县| 灵宝市| 深水埗区| 旺苍县| 台湾省| 道孚县| 南昌市| 伊金霍洛旗| 江北区| 琼海市| 城口县| 恩平市| 新昌县| 乌苏市| 威远县| 崇阳县| 凌源市| 焦作市| 盘锦市| 潼关县| 汤原县| 丽江市| 茌平县| 基隆市| 平潭县| 城步| 遂溪县| 米易县| 乌鲁木齐县| 高青县| 屏山县| 瓦房店市| 阿拉善左旗| 色达县| 宜川县| 秦皇岛市| 凤山县|