[struts] getAttribute()

1.tomcat調用struts2的filter後,再forward到jsp的時候的代碼類似如下,
String jsp = "xxxx.jsp";
HttpServletRequest req = new StrutsRequestWrapper(request);
request.getRequestDispatcher(jsp).forward(req, response); 

2.在jsp上使用${xxxx}約等於request.getAttribute("xxxx");


3.在jsp裏調用getAttribute方法時,實際是調用的StrutsRequestWrapper的getAttribute方法


4.而這個類的getAttribute方法
的實現會獲取當前的action對象然後調用其getXxxx()方法


5.這並不是el本身有的功能,而是struts2通過javaweb的request包裝機制實現了調用action的getXxxx()方法。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章