当前位置:网站首页>@Controller和@RestController的区别
@Controller和@RestController的区别
2022-07-15 15:25:00 【离离原上草77】
@RestController注解相当于@ResponseBody + @Controller合在一起的作用。
如果只是使用@RestController注解Controller,则Controller中的方法无法返回jsp页面,或者html,配置的视图解析器 InternalResourceViewResolver不起作用,返回的内容就是Return 里的内容。
如果需要返回到指定页面,则需要用 @Controller配合视图解析器InternalResourceViewResolver才行。
如果需要返回JSON,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。
3)如果需要返回JSON,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。
注意:在controller类中,添加RestController后后台不能重定向页面,如果需要重定向页面,则需要使用Controller,在需要返会数据的方法上添加@ResponseBody
边栏推荐
- C#编写一个GUI工具并反编译
- What fault simulation does the chaosblade now support for the database? Do the teachers have any information?
- xstream解析xml的时候报错AbstractReflectionConverter$UnknownFieldException
- 信息系统项目管理师核心考点(十一)物联网两项关键技术和架构
- Redis05: redis transactions
- @What is tap
- Modbus 超时时间设置
- 信息系统项目管理师核心考点(八)软件集成技术
- 移动机器人学(一) 数学基础
- Chess all in one
猜你喜欢

电商平台后台管理系统--->项目前期准备(需求分析、系统设计、环境搭建与配置文件)

uni-app打电话功能

Redis05: redis transactions

Information system project manager core examination site (IX) organizational structure type

信息系统项目管理师考前10天极限冲刺+答案(七)

Realize the side-by-side display of two elements (including the explanation of some flex attributes)

把后台拿到的数据渲染在页面上 对象与数组的渲染方式示例

uni-app 标签跳转

Salesforce Certified Sharing and Visibility Designer (SU20)认证考试总结

动态规划 | 0-1背包问题
随机推荐
uni-app表单数据不复现
(pc+wap) Zhimeng template waterproof building materials website
Introduction to STM32 IO port mode
How to create threads
Redis03: five common data types of redis
Precautions for implementing the campaign influence model in salesforce
SourceInsight 插件使用
Chess all in one
科科过信管】信管论文写作要求-不合格论文
STM32 IAP远程更新
Code implementation of jump between IAP bootload and app
Information system project managers must recite the core examination points (I) six elements of the national information system
Connecting with enterprise wechat, customer relationship management can also be very simple!
理财平台哪个最安全收益怎么样
Super Ping tool
C#编写一个GUI工具并反编译
E-commerce platform background management system --- > system detailed design (user login, commodity management module)
Redis05: redis transactions
NiFi ListSFTP精讲
Redis02: install redis in Linux Environment