jquery post json data to spring contoller
please refer:
http://stackoverflow.com/questions/15532323/spring-3-2-jackson2-400-bad-request
http://ahlearns.wordpress.com/2011/07/29/spring-3-mvc-requestbody-deserialization-of-custom-list-objects/
1:首先要配置jacksonMessageConverter。
2:ajax要设置contentType:"application/json; charset=utf-8"(否则会报application/x-www-form-urlencoded not supported), data要用JSON.stringify(your json data).
3:在controller方法里只能有一个参数,且要加上@RequestBody, 最好用javaBean[ ]接收, 不要用ArrayList<POJO>, 因为type erasure导致你得到的是ArrayList<HashMap>。或者你可以写一个temp POJO2 extends ArrayList<POJO>,然后用POJO2去接, 这样泛型信息会保留下来,(not test and not recommend)
jquery post json to spring contoller(spring version 3.1)
猜你喜欢
转载自lg-asus.iteye.com/blog/2047314
今日推荐
周排行