spring mvc3 REST中的一个注意点,比如:
@RequestMapping(value = "/addarticle/{name}", method = RequestMethod.POST)
public ModelAndView addArticleCategoriesForName(@PathVariable String name) {
List<Category> categories = new ArrayList<Category>();
Category category = new Category();
category.setName(name);
System.out.println(name);
categories.add(category);
ModelAndView mav = new ModelAndView("articleXmlView", BindingResult.MODEL_KEY_PREFIX + "category", categories);
return mav;
}
返回ModelAndView时,记得要用BindingResult.MODEL_KEY_PREFIX + 实体类的名,这个好象是个BUG还是不完善的地方,见:
http://forum.springsource.org/showthread.php?73221-Strange-bean-property-binding-result-in-Rest-Castor-result&p=271888#post271888
posted on 2011-07-25 09:24
墙头草 阅读(1732)
评论(1) 编辑 收藏