gpt4 book ai didi

spring-mvc - SpringMVC : Adding a mediatype to static resources to be served

转载 作者:行者123 更新时间:2023-12-04 16:55:45 27 4
gpt4 key购买 nike

在我的spring-mvc应用程序中,我正在提供一些静态资源。 JavaScrips,CSS和图像可以正确提供,但是也有一些json文件没有交付。

因此,我可以在浏览器中看到此文件:
http://localhost:8080/path/to/resources/example.png

但是我没有收到该文件(在同一目录中):
http://localhost:8080/path/to/resources/example.json

我得到这个:

DEBUG: org.springframework.web.servlet.resource.ResourceHttpRequestHandler - No media type found for ServletContext resource [/resources/path/to/resources/example.json] - returning 404

因此,我假设我需要在配置中添加此媒体类型扩展名(.json)的某个位置,但找不到它。

请帮助!

最佳答案

将此添加到您的web.xml

<mime-mapping>
<extension>json</extension>
<mime-type>application/json</mime-type>
</mime-mapping>

关于spring-mvc - SpringMVC : Adding a mediatype to static resources to be served,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6224972/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com