例如:
<table width="200" border="1">
<tr>
<td>姓名</td>
<td>年龄</td>
<td>操作</td>
</tr>
<tr>
<td><input type="text" value="张三"/></td>
<td><input type="text" value="17"/></td>
<td><input type="button" value="+"/></td>
</tr>
<tr>
<td><input type="text" value="李四"/></td>
<td><input type="text" value="16"/></td>
<td><input type="button" value="-"/></td>
</tr>
<tr>
<td><input type="text" value="王五"/></td>
<td><input type="text" value="15"/></td>
<td><input type="button" value="-"/></td>
</tr>
</table>
<input type="button" value="保存"/>一行对应一个对象,数据库里都有对应的Id,这里的姓名和年龄都可以修改,点击 后面的 + 号 可以新增,点击 - 号可删除
,最后保存是要把修改的内容 提交全部更新。
这块还有几天要上线了,有些理不清楚了,希望指点下我该怎么做。
<table width="200" border="1">
<tr>
<td>姓名</td>
<td>年龄</td>
<td>操作</td>
</tr>
<tr>
<td><input type="text" value="张三"/></td>
<td><input type="text" value="17"/></td>
<td><input type="button" value="+"/></td>
</tr>
<tr>
<td><input type="text" value="李四"/></td>
<td><input type="text" value="16"/></td>
<td><input type="button" value="-"/></td>
</tr>
<tr>
<td><input type="text" value="王五"/></td>
<td><input type="text" value="15"/></td>
<td><input type="button" value="-"/></td>
</tr>
</table>
<input type="button" value="保存"/>一行对应一个对象,数据库里都有对应的Id,这里的姓名和年龄都可以修改,点击 后面的 + 号 可以新增,点击 - 号可删除
,最后保存是要把修改的内容 提交全部更新。
这块还有几天要上线了,有些理不清楚了,希望指点下我该怎么做。
解决方案 »
- struts中tiles框架的问题
- oracle数据库utf-8编码 页面areatext如何控制字符输入长度比较理想
- 求教spring管理多个sessionFactory问题
- 急用!!!~~~~~~~
- 求助SSH上传下载代码
- displaytab_tld使用问题,来者有分
- 关于iis+mysql+resin怎么配的问题
- 一个关于statement.executeUpdate(sql)的问题
- javax.servlet.ServletException: No ResultSet was produced
- 数据库连接错误!高手帮看下
- JSP的两个小问题
- 请问java连接数据库怎么删除多条记录啊!!应该怎么样做啊?
当后台取的时候根据id来取里面的内容js添加删除、应该不是很难!
如果有问题可以加我Q260575364
新增的id肯定为空,只有更新的才有id
页面一行: <input type="hidden" name="ids"/> <input type="text" name="names" />
这样提交后 ,后台 ids[i]与 names[i]能对应上不?
怎么就是觉得不可靠,而且一个对象的属性很多,就有很多数组,那样封装对象起来一个个set 看起来有些繁琐。
想问问还有更好的办法没有。
String obj = null;
try {
String[] functionId = spl(key);
ContractInformation cifo = contractInformations.get(functionId[1]);
Method putMethod = cifo.getClass().getMethod("get"+functionId[0]);
obj = putMethod.invoke(cifo).toString();
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
public void setContractInformation(String key,String value){
Class[] argsClass = new Class[1];
argsClass[0] = value.getClass();
String [] str = new String[1];
str[0] = value;
String[] functionId = spl(key);
ContractInformation cifo = contractInformations.get(functionId[1]);
if(cifo==null){
cifo = new ContractInformation();
}
try {
Method putMethod = cifo.getClass().getMethod("set"+functionId[0],argsClass);
putMethod.invoke(cifo, str);
contractInformations.remove(functionId[1]);
contractInformations.put(functionId[1],cifo);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setContractInformations(
Map<String, ContractInformation> contractInformations) {
this.contractInformations = contractInformations;
}
public Map<String, ContractInformation> getContractInformations() {
return contractInformations;
}
jsp:<c:forEach var="cifo" items="${opertionForm.contractInformations}" varStatus="status">
<html:hidden property="contractInformation(informationId_${cifo.key})"/>
<tr>
<td>
<html:text property="contractInformation(informationNumbers_${cifo.key})" />
</td>
<td>
<html:text property="contractInformation(productRange_${cifo.key})" />
</td>
<td>
<html:text property="contractInformation(unit_${cifo.key})" />
</td>
<td>
<html:text property="contractInformation(unitPrice_${cifo.key})" styleId="a${status.index}" onblur="blurText(${status.index})"/>
</td>
<td>
<html:text property="contractInformation(quantity_${cifo.key})" styleId="b${status.index}" onblur="blurText(${status.index})"/>
</td>
<td>
<input id="c${status.index}" name = "sumMoneyH" type ="text" value = "???"/>
</td>
<td>
非临时数据
</td>
</tr>
</c:forEach>
String str=string;
str =str.replaceFirst(str.substring(0, 1),str.substring(0, 1).toUpperCase()) ;
String[] functionId = str.split("_");
return functionId;
}