Struts2怎样将数据自动填充到Form里?

2024-12-11 14:44:30
推荐回答(2个)
回答1:

一般在页面取值都是这样做的:
后台在action中request.setAttribute("key",value);
前台在jsp相应的框 value="<%=request.getAttribute("key")%>"就能取出来了。
用textarea的话,就<%=request.getAttribute("key")%>
不管存在哪里,后台都要request.setAttribute("key",value);
前台用request.getAttribute("key")接收。
这里的key可以随便取名字,前后台一样就可以了,
value是要传的值。
另外可以用EL表单提取:











${item.id} ${item.name} ${item.password}

回答2:

Struts2好像没有form这个东西的吧