ssm框架的@ResponseBody

@ResponseBody:不走视图处理器,而是让数据直接输出

比如返回一个类,它会帮你转成json格式:

@RequestMapping(value="update",method=RequestMethod.GET)
@ResponseBody
public JsResult login(@RequestParam("id")String id,@RequestParam("week")String week,@RequestParam("userNum")String userNum,@RequestParam("startClass")int startClass,@RequestParam("cosid")String cosid,@RequestParam("classSum")int classSum,@RequestParam("classroom")String classroom,@RequestParam("className")String className,@RequestParam("lineClassNum")String lineClassNum){
boolean result=timetableservice.updatetimetable(id, week, userNum, startClass, cosid, classSum, classroom, className, lineClassNum);
jsresult=new JsResult(result);
return jsresult;
}

其实这个注解和@Controller结合就变成了只要一个注解的@RestController

你可能感兴趣的:(ssm框架的@ResponseBody)