Skip to content

WebMVC RequestMapping Produces Problem [SPR-16448] #20993

@spring-projects-issues

Description

@spring-projects-issues

Uwe Grünheid opened SPR-16448 and commented

Hey,

maybe I am totally wrong in my expectations of using rest APIs so sorry if this request sounds to stupid but I was actually working on a legacy project and got a problem with having two media types produces via @RequestMapping-Annotation.

In my opinion the actual delivering of request mapping especially it's handling of produced media types could be improved if there would be a check in AbstractMessageConverterMethodProcessor.writeWithMessageConverters(...) if an explicit content type was given in the response entity.

I made a little showcase which could be found in the referenced URL. Normally my old legacy service just returned a string like media type text/plain. But for getting this service towards REST I also inserted a application/json resource in my exception handler. I know that there are some other ways to get it working. For example I could just wrap my String into an resource object or just deliver also a string as error response.
But the funny fact that everything works perfectly fine if just removing the produces flag in the annotation (like picture 3) made me thinking that this could also be handled in the HttpEntityMethodProcessor.

Cheers & Thanks for taking a look :)
Uwe


Affects: 4.3.14

Reference URL: https://github.com/mixaaaa/produces-problem

Attachments:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions