首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

SpringMVC批量更新有关问题

2012-06-24 
SpringMVC批量更新问题发现SpringMVC批量删除的时候只需要删除id属性即可。然后参数用 ListInteger 封装

SpringMVC批量更新问题
发现SpringMVC批量删除的时候只需要删除id属性即可。

然后参数用 List<Integer> 封装起来。

就可以在这个集合中找到这些id了。


现在发现批量更新的时候 List<MyClass> 用我自己的类的时候发现得不到数据。

- -..


谁做过SpringMVC的批量更新的。。。


教授一下 。。。



[解决办法]
springmvc 要批量更新调用的也是dao 层操作
我用的springmvc ibatis ,得到批量的数据id组装成string,最终都是为了在批量的sql里面 做成这种格式
updage ******* where id in (1,2,3)
至于你用什么格式接收controller 得到的ids, 最终的格式是分开成单个id
[解决办法]
继承的这个JdbcDaoSupport 类,怎么做更新啊 可以给我一个详细的资料吗,谢谢!qq:394951514
[解决办法]
spring的jdbc封装吗?
例子:

Java code
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} 

热点排行