Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain when to use MediaType constants [SPR-13531] #18108

Closed
spring-issuemaster opened this issue Oct 2, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Oct 2, 2015

Manuel Jordan opened SPR-13531 and commented

Hello

I know work around

@RequestMapping(value="something", 
			    method=RequestMethod.GET,
			    produces=MediaType.APPLICATION_XML_VALUE)
@RequestMapping(value="something", 
			    method=RequestMethod.GET,
			    produces=MediaType.APPLICATION_JSON_VALUE)

It for REST working around the @ResponseBody

To load a JSP/HTML view my method returns a String to be resolved later through a ViewResolver's implementation

I am wondered when has sense use:

  • MediaType.TEXT_HTML_VALUE

Thank you.


Affects: 4.1 GA, 4.2 GA

Referenced from: commits b7b8d85

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 23, 2015

Rossen Stoyanchev commented

It's there for completeness but you're right to point out it probably won't be used in an @RequestMapping method. That said you could use it anywhere where you want "text/html", could be in tests, or elsewhere like saving a report to a database, etc.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 23, 2015

Manuel Jordan commented

Thanks by the explanation. With the best intention that explanation (perhaps a little more expanded) would added to the reference documentation? It to avoid confusions for the community.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 26, 2015

Rossen Stoyanchev commented

I struggle to see where to the reference documentation and where? We could add Javadoc to the constant. Is that what you meant by reference documentation? If not please clarify as this is a rather fine-grained detail, the kind that's usually not reflected in the reference.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 27, 2015

Manuel Jordan commented

Hello

I struggle to see where to the reference documentation and where?

perhaps through a special note when is covered the @RequestMapping's produces attribute. It for Json/xml sections.
Therefore that note should be added twice.

We could add Javadoc to the constant

Yes too.

Is that what you meant by reference documentation?

I mean, In Spring Framework I can see Reference and API links, if I do click on Reference I arrive to Spring Framework Reference Documentation

If not please clarify as this is a rather fine-grained detail, the kind that's usually not reflected in the reference.

For me, being honest and polite, should be in both places Reference and API. Of course has more sense in API, but seems our perspectives are little different

Thanks by your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.