Difference between @RestController and @RepositoryRestController

醉酒当歌 提交于 2019-12-29 05:47:45

问题


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


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/34512878/difference-between-restcontroller-and-repositoryrestcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!