【发布时间】:2014-12-18 17:34:53
【问题描述】:
我是 Spring 新手。我想使用@RequestBody 注释或@ResponseBody 注释,而不是使用Model 和View。
以下是我想要使用的当前具有模型和视图的方法
@ResponseBody注解
@RequestMapping(value="/user/limits", method=RequestMethod.GET)
protected ModelAndView getUserLimits(HttpServletRequest request,
HttpServletResponse response, Authentication authentication) throws Exception {
ModelAndView mv = new ModelAndView();
mv.setView(new MappingJackson2JsonView());
if(authentication == null){
response.setStatus( HttpServletResponse.SC_FORBIDDEN);
return null;
}
String userid = authentication.getName();
mv.addObject("limits", Service.getlimitsInfo(userid));
return mv;
}
没有Model和View如何使用指定的注解。
【问题讨论】: