?
?@Override ?? ?protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ?? ??? ?//完成寻找子控制器的过程 ?? ??? ?//浏览器:http://localhost:8080/t266_mvc/book.action?methodName=add ?? ??? ?//目标:BookAction.add().... ?? ??? ?/** ?? ??? ? * ?? ?思路: ?? ??? ? * ?? ?1.从浏览器URL中获取到"/book"字符串 ?? ??? ? * ?? ?2.在子控制器中拿到BookAction ?? ??? ? * ?? ?3.BookAction.add() ?? ??? ? */ ?? ??? ?StringBuffer uri = req.getRequestURL(); ?? ??? ?uri.substring(uri.lastIndexOf("/"), uri.lastIndexOf(".")); //?? ??? ?action = BookAction ?? ??? ?ActionSupport action = actions.get(uri); //?? ??? ?ActrionSupport action = new BookAction() ?? ??? ?action.execute(req, resp); ?? ?}
|