SpringMVC批量更新问题 发现SpringMVC批量删除的时候只需要删除id属性即可。然后参数用 List<Integer> 封装起来。就可以在这个集合中找到这些id了。现在发现批量更新的时候 List<MyClass> 用我自己的类的时候发现得不到数据。- -..谁做过SpringMVC的批量更新的教授一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 springmvc 要批量更新调用的也是dao 层操作我用的springmvc ibatis ,得到批量的数据id组装成string,最终都是为了在批量的sql里面 做成这种格式updage ******* where id in (1,2,3)至于你用什么格式接收controller 得到的ids, 最终的格式是分开成单个id spring的jdbc封装吗?例子:public class JdbcActorDao implements ActorDao { private JdbcTemplate jdbcTemplate; public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } public int[] batchUpdate(final List actors) { int[] updateCounts = jdbcTemplate.batchUpdate( "update t_actor set first_name = ?, last_name = ? where id = ?", new BatchPreparedStatementSetter() { public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setString(1, ((Actor)actors.get(i)).getFirstName()); ps.setString(2, ((Actor)actors.get(i)).getLastName()); ps.setLong(3, ((Actor)actors.get(i)).getId().longValue()); } public int getBatchSize() { return actors.size(); } } ); return updateCounts; } // ... additional methods} 【Structs】为什么加入form-bean就错? AOP??? 不显示删除回复显示所有回复显示星级回复显示得分回复 java 抛的数据库连接异常,求解?[ 怎么可以读到WEB-INF下面的XML文件? 关于xfire的问题 关于struts中validation.xml的问题 关于访问java中同一个对象问题 如何在javabean中获取request对象 [struts-tile]问一个tile的基本概念 小弟想请教一个问题:关于int和Integer,它们是怎么回事呀?谢谢 求大神指教J2ee 求一个简单实用的新闻发布系统
我用的springmvc ibatis ,得到批量的数据id组装成string,最终都是为了在批量的sql里面 做成这种格式
updage ******* where id in (1,2,3)
至于你用什么格式接收controller 得到的ids, 最终的格式是分开成单个id
例子:public class JdbcActorDao implements ActorDao {
private JdbcTemplate jdbcTemplate; public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
} public int[] batchUpdate(final List actors) {
int[] updateCounts = jdbcTemplate.batchUpdate(
"update t_actor set first_name = ?, last_name = ? where id = ?",
new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setString(1, ((Actor)actors.get(i)).getFirstName());
ps.setString(2, ((Actor)actors.get(i)).getLastName());
ps.setLong(3, ((Actor)actors.get(i)).getId().longValue());
} public int getBatchSize() {
return actors.size();
}
} );
return updateCounts;
} // ... additional methods
}