@RestController == @ResponseBody + @Controller 的效果
1. 如果在controller层使用@Controller注解,则Controller中的接口方法无法返回jsp页面,配置的视图解析器 InternalResourceViewResolver不起作用,返回的内容就是Return 里的内容。
2. 如果需要返回到指定页面,则需要用 @Controller配合视图解析InternalResourceViewResolver才行。如果需要返回JSON格式,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。
但是使用@RestControlle弊端就是你要是不想返回json格式也不能单独注解了,因为在全局注解过了。(个人见解)