有人可以提供一些关于如何做的指导或代码示例吗?
public class HomePageController extends HttpServlet {
private static final Logger log = Logger.getLogger(HomePageController.class);
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.debug("Into the HomePageController...");
showPage(request, response, HOME_PAGE_URL);
}
private void showPage(HttpServletRequest request, HttpServletResponse response, String viewName) throws ServletException, IOException {
log.debug("Displaying " + viewName + " page now...");
String url = TEMPLATE_PAGE_URL + "?gotoPage=" + viewName;
//forward the request to the page
request.getServletContext().getRequestDispatcher(url).forward(request, response);
}
}