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

查看:47
本文介绍了@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 Data REST 功能的自定义控制器的方法.

According to the annotation the RepositoryRestController is a way to provide custom controllers that still take advantage of Spring Data REST functionality.

Spring Data REST 参考指南,15.6.覆盖 Spring Data REST 响应处理程序:

Spring Data REST Reference Guide, 15.6. Overriding Spring Data REST 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 Data REST 基本路径并将在此基本路径下提供服务.

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天全站免登陆