JSP中 while(Rs.next()) 代码
<%while(Rs.next()){ %>
<textarea id="rep<%=i%>"name="mo_reply<%=i%>" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<%}Rs.close();%>如果rs.next循环了三次 会生成3个textarea <textarea id="rep1"name="mo_reply1" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<textarea id="rep2"name="mo_reply2" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<textarea id="rep3"name="mo_reply3" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
怎么在Action中 获得对应textarea 里的内容呢
<%while(Rs.next()){ %>
<textarea id="rep<%=i%>"name="mo_reply<%=i%>" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<%}Rs.close();%>如果rs.next循环了三次 会生成3个textarea <textarea id="rep1"name="mo_reply1" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<textarea id="rep2"name="mo_reply2" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<textarea id="rep3"name="mo_reply3" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
怎么在Action中 获得对应textarea 里的内容呢
<textarea id="rep<%=i%>"name="mo_reply" rows="1" cols="50" ></textarea>
<html:link action="/addmoodreply.do" ><img src="images/other/ensure.png"/></html:link> 取消
<%}Rs.close();%>1. name用相同的名字,在Action里取数据里时候用request.getParameterValues("mo_reply");会得到一个数组。
2. 你再循环这个数组得到你想要的数据就OK了
while(e.hasMoreElements()){
System.out.println(e.nextElement());
}
<textarea id="rep<%=i%>"name="mo_reply<%=i%>" rows="1" cols="50" ></textarea>
=><textarea id="rep<%=i%>"name="mo_reply" rows="1" cols="50" ></textarea>
那个name不用变了吧,我只记得checkbox都用的相同的名字,然后你用2楼的方法在action里通过
request.getParameterValues("mo_reply");试试!