我想使用spring mvc convert json到一个像
这样的对象 @RequestMapping(value = "searchPolygonArea/", method = RequestMethod.GET,params = {"region != null"})
public @ResponseBody ResultBean <List <Spot>> searchPolygonArea(@ModelAttribute (value="regionModel") Region regions,@RequestParam(value="region") Region region){
return new ResultBean <List<Spot>> ();
}
@InitBinder(value="regionModel")
public void initBinder(WebDataBinder dataBinder,@RequestParam(value="region") final String regionParams){//,
dataBinder.registerCustomEditor (Region.class, new PropertyEditorSupport (){
Region value ;
@Override
public Object getValue () {
return new Region ();
}
@Override
public void setAsText (String text) throws IllegalArgumentException {
System.out.println (text);
try {
value = JSONUtils.json2Obj (text, Region.class);
}
catch (Exception e) {
e.printStackTrace();
}
}
});
}
但是setAsText和getValue没有执行,我不知道为什么。