开发者

Is there any special configuration to cause "application/json" mime type to be accepted Tomcat 6.0 (Spring MVC 3.0)?

开发者 https://www.devze.com 2023-03-03 16:01 出处:网络
Is there any special configuration one must do? or should it work out of the box? e.g. should I add something like this to make it work?

Is there any special configuration one must do? or should it work out of the box?

e.g. should I add something like this to make it work?

 <mime-mapping>
    <extension>json</extension>
    <mime-type>application/json</mime-type>
</mime-mapping> 
开发者_运维百科


If you are trying to make Tomcat serve .json files with the right mime type then yes, you will need to add that mime type declaration to the conf/web.xml file.

If you're serving dynamically generated JSON then it really shouldn't matter: you can set any mime type using the setContentType function.


It seems there is no special configuration, it accepts any application/json requests out of the box, I was suspecting the wrong issue.

See this other question of mine, it has the original issue and the surprising silly solution: JQuery, Spring MVC @RequestBody and JSON - making it work together

0

精彩评论

暂无评论...
验证码 换一张
取 消