ex6_16.txt
来自「j2ee core design patterns」· 文本 代码 · 共 25 行
TXT
25 行
Example 6.16 Command and Controller Strategy
/** This processRequest method is invoked from both
* the servlet doGet and doPost methods **/
protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
java.io.IOException {
String resultPage;
try {
RequestHelper helper = new RequestHelper(request);
/** the getCommand() method internally uses a
* factory to retrieve command objects as follows:
* Command command = CommandFactory.create(
* request.getParameter(op));
**/
Command command = helper.getCommand();
// delegate request to a command object helper
resultPage = command.execute(request, response);
} catch (Exception e) {
LogManager.logMessage("FrontController", e.getMessage());
resultPage = ApplicationResources.getInstance().getErrorPage(e);
}
dispatch(request, response, resultPage);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?