Struts中bean:write tag读取数据的顺序问题

Mr. xiaodongx 问了我这个问题,没做实验不敢妄下结论,现写如下代码test一下

code block 1

public class TestAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

TestForm actionform = (TestForm) form;
actionform.setP("p1");
TestForm actionform2=new TestForm();
actionform2.setP("p2");
request.getSession().setAttribute("vo",actionform2);
request.setAttribute("vo",actionform);

return mapping.findForward("input");

}

code blcok2

<bean:write name="vo" property="p"/>

此时页面显示p1

如果屏蔽掉绿色代码,页面显示p2

于是得出结论

<bean:write >标签先从request中读取数据,没有就从session中读,再没有就报错

你可能感兴趣的:(bean,struts)