Controller中返回数据和页面的差别
1.返回数据是需要添加@ResponseBody,
2.返回到页面时,@Controller不可以使用@RestController代替,因为在返回页面的方法上不需要@ResponseBody;
@ResponseBody
@RequestMapping("/success")
public String success(){
//classpath:/templates/success.html
return "success";
}
如果是上面的就无法访问到success页面,返回的是success;
@RequestMapping("/success")
public String success(){
//classpath:/templates/success.html
return "success";
}
这样才可以访问的到。