@RestController 和 @RepositoryRestController 的区别 [英] Difference between @RestController and @RepositoryRestController

查看:81
本文介绍了@RestController 和 @RepositoryRestController 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显示这两个注释之间区别的典型用例 code 是什么 - 即 @RestController@RepositoryRestController - ?

What is the typical use case code that shows the difference between those two annotations - meaning the @RestController and the @RepositoryRestController - ?

推荐答案

根据注解,RepositoryRestController 是一种提供自定义控制器的方式,该控制器仍然利用 spring 数据休息功能

According to the annotation the RepositoryRestController is a way to provide custom controllers that still take advantage of spring data rest functionality

http://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.overriding-sdr-response-handlers

有时您可能想为特定的对象编写自定义处理程序资源.要利用 Spring Data REST 的设置,请发送消息转换器、异常处理等,使用@RepositoryRestController 注释而不是标准的 Spring MVC@Controller 或 @RestController.

Sometimes you may want to write a custom handler for a specific resource. To take advantage of Spring Data REST’s settings, message converters, exception handling, and more, use the @RepositoryRestController annotation instead of a standard Spring MVC @Controller or @RestController.

最重要的是,RepositoryRestController 知道 spring 数据休息基本路径并将在此基本路径下提供服务.

Most importantly the RepositoryRestController is aware of the spring data rest base path and will be served under this base path.

这篇关于@RestController 和 @RepositoryRestController 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆