-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Gerrit Brehmer opened SPR-7278 and commented
The recommended way to develop REST-style webservices is the usage of @ResponseBody annotation and HttpMessageConverter instead of generating a model and a view (ContentNegotiatingViewResolver etc.).
But there are some limitations, that make things hard to handle:
- ExceptionResolver support
@RequestBodyis only supported with@ExceptionHandlerannotation. I need a centralized exception handling to generate a special error object as the return value. So I must wrote a method in each controller class to delegate to the centralized exception handler. I think the ExceptionResolver-interface is more like an AOP-approach, with no glue code.- ExceptionResolver also have some nice standard implementations like SimpleMappingExceptionResolver, where I can handle the returned HTTP status code very easy. This is also not supported by
@ExceptionHandlerout of the box
- 'useNotAcceptableStatusCode' from ContentNegotiatingViewResolver (so for some features, I must also configure view-handling)
- simple and easy to use attribute to enable NOT_ACCEPTABLE Http Status code
- missing option for enabling global
@ResponseBody-likehandling instead of annotate all methods (e.g. in AnnotationMethodHandlerAdapter)
I also would recommend the full HttpMessageConverter way (@RequestBody & @ResponseBody) without view handling, so it would be nice, if @ResponseBody has fewer limitations. Additionaly it would be great, if the documentation have some notes about the recommended way for webservice-only REST-style applications (with hints to the limitations above)
Affects: 3.0.2
Issue Links:
- @ExceptionHandler doesn't handle exceptions from other controllers [SPR-8124] #12776
@ExceptionHandlerdoesn't handle exceptions from other controllers ("is duplicated by") - Add equivalent of JAX-RS @Produces to Spring MVC [SPR-7353] #12012 Add equivalent of JAX-RS
@Producesto Spring MVC
Referenced from: commits e5eceaf
1 votes, 2 watchers
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement