如何 在struts2 action中 取jsp 动态生成的文本框的值

例如
jsp页面如果:
<%
for(int i=0;i<n;i++){
%>
<input type="text" name="xzt<%=i %>">
<%}%>
action中,怎么取到这些文本框的值

弄个隐藏域,把n值传到后台,然后后台根据n的值遍历,reque。getparameter(“xzt”+i),追问

ActionSupport中没有reque这个对象

追答

struts中可通过ttpServletRequest request = ServletActionContext.getRequest();得到response,request,session等

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-14
name属性的值设为相同的 在action中用List<String> 接收,然后遍历list就OK了 希望回答对您有帮助,望采纳 谢谢
第2个回答  2012-05-13
错了,只能穿字符串。你需要通过String str=String.valueOf("i"),然后在嵌套在表单中
<input type="text" name="xzt“ value="<%=str%>">,你那样写问题比较多。
第3个回答  2012-05-14
定义成同名的就可以,action中定义整型数组接收就行了,需要生成getter/setter方法
如:jsp
<input type="text" name="test">
<input type="text" name="test">
<input type="text" name="test">
action:
private int test[];
相似回答