中央控制运行//初始化子控制器(集合),经过初始化,actions容器里面就有的子控制器
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//完成寻找子控制器
//浏览器:http://localhost:8080/javaEE_MVC/book.action?methodName=add
//目标:bookAction.add()..
/**
* 思路:
* 1.从浏览器url中获取“/book”字符串
* 2.在子控制器容器中拿到bookAction
* 3.bookAction.add()..
*/
String uri = req.getRequestURI();
uri=uri.substring(uri.lastIndexOf("/"), uri.lastIndexOf("."));
//action
ActionSupport action = actions.get(uri);
action.execute(req, resp);
}
子控制器需要拿到的方法
运行原理图
运行结果
思维导图