下面的存储我应该怎么实现!someList2是存在session中最多时候有4笔数据(这个数据不定)
最不好的就是后面还跟这text的值要一笔一笔的save到数据库
用的是struts1.x 在下个Action中怎么判断去存呢?<%
int i=1; //表示几笔记录
int j=1; //这里用于 text的name 好在下个页码 接受值!
%>
<c:forEach items="${someList2}"var="u">
<tr>
<th scope="row" abbr="Model" class="spec"><%=i++%></th>
<th scope="row" abbr="G5 Processor" class="specalt"><c:out value="${u.lh }"></c:out></th>
<th scope="row" abbr="Frontside bus" class="spec"><c:out value="${u.pm}"></c:out></th>
<th scope="row" abbr="L2 Cache" class="specalt"><c:out value="${u.gg}"></c:out></th>
<th scope="row" abbr="Model" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "8"onKeyDown="toNext();"></th>
<th scope="row" abbr="G5 Processor" class="specalt"><input name = "lnumber<%=j++ %>" type = "text"size = "15"onKeyDown="toNext();"></th>
<th scope="row" abbr="Frontside bus" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "10"onKeyDown="toNext();"></th>
<th scope="row" abbr="L2 Cache" class="specalt"><input name = "lnumber<%=j++ %>" type = "text"size = "10"onKeyDown="toNext();"></th>
<th scope="row" abbr="Model" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "20"onKeyDown="toNext();"></th>
</tr>
</c:forEach>
</table>
最不好的就是后面还跟这text的值要一笔一笔的save到数据库
用的是struts1.x 在下个Action中怎么判断去存呢?<%
int i=1; //表示几笔记录
int j=1; //这里用于 text的name 好在下个页码 接受值!
%>
<c:forEach items="${someList2}"var="u">
<tr>
<th scope="row" abbr="Model" class="spec"><%=i++%></th>
<th scope="row" abbr="G5 Processor" class="specalt"><c:out value="${u.lh }"></c:out></th>
<th scope="row" abbr="Frontside bus" class="spec"><c:out value="${u.pm}"></c:out></th>
<th scope="row" abbr="L2 Cache" class="specalt"><c:out value="${u.gg}"></c:out></th>
<th scope="row" abbr="Model" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "8"onKeyDown="toNext();"></th>
<th scope="row" abbr="G5 Processor" class="specalt"><input name = "lnumber<%=j++ %>" type = "text"size = "15"onKeyDown="toNext();"></th>
<th scope="row" abbr="Frontside bus" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "10"onKeyDown="toNext();"></th>
<th scope="row" abbr="L2 Cache" class="specalt"><input name = "lnumber<%=j++ %>" type = "text"size = "10"onKeyDown="toNext();"></th>
<th scope="row" abbr="Model" class="spec"><input name = "lnumber<%=j++ %>" type = "text"size = "20"onKeyDown="toNext();"></th>
</tr>
</c:forEach>
</table>
图片介绍:<input type="text" name="tpjies(1)" /> <input type="file" name="tpfiles(1)" /> <br>
图片介绍:<input type="text" name="tpjies(2)" /> <input type="file" name="tpfiles(2)" /> <br>ActionForm
private Map tpfiles = new HashMap();
private Map tpjies = new HashMap();action里面解析他们就可以了
图片介绍: <input type="text" name="tpjiesb(i)" /> <input type="file" name="tpfilesb(i)" /> <br>
图片介绍: <input type="text" name="tpjiesc(i)" /> <input type="file" name="tpfilesc(i)" /> <br>
java.util.Enumeration params = request.getParameterNames("lnumber1");
while (params.hasMoreElements()) {
String key = (String) params.nextElement();//取名
//存储
}以上取得的是第一笔的数据,循环中可以做存储处理以此类推,第2.3.4笔数据都一样的
String[] checkboxs = request.getParametersValues("+checkbox的name属性+")
假如我int j= (list1.size());//获取当前几笔数据!
假如是3笔我就生成 下面的insert 假如是4笔就就成4个pstmt 这样if太吃力了吧pstmt2=con.prepareStatement("insert into blbgtb2 values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
//数据1
pstmt1.addBatch();
//数据2
pstmt2.addBatch();//数据3
pstmt3.addBatch();