📄 ex6_43.txt
字号:
Example 6.43 Implementing View Handler Strategy: WebApplicationController
// Application Controller Implementation to handle Web
// Application Requests
class WebApplicationController implements ApplicationController {
. . .
// Handle View Navigation and Dispatching to appropriate View
public void handleResponse(RequestContext requestContext,
ResponseContext responseContext) {
ViewFactory viewFactory = ViewFactory.getInstance();
// Identify view template based on logical view name, user agent,
// locale, etc
String viewTemplate = viewFactory.getViewTemplate(
requestContext, responseContext.getLogicalViewName());
// dispatch to view processor
dispatch(requestContext.getRequest(), responseContext.getResponse(),
viewTemplate);
}
public void destroy() { }
// dispatcher method
private void dispatch(HttpServletRequest request,
HttpServletResponse response, String page) {
try {
RequestDispatcher dispatcher = request.getRequestDispatcher(page);
dispatcher.forward(request, response);
} catch(Exception e) {
// Handle Exception
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -