gpt4 book ai didi

java - Spring MVC :resources needs to map to the same filename?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:08:27 26 4
gpt4 key购买 nike

如果我的 web-context.xml 中的 mvc:resources 标记未映射到相同的文件名,我将在 Jetty 中收到 404:

<mvc:resources mapping="/some-file" location="/WEB-INF/js/some-file.js" />

以下工作正常的地方:

<mvc:resources mapping="/some-file.js" location="/WEB-INF/js/some-file.js" />

如何将文件映射到 URL 空间中的不同文件名?

最佳答案

我建议您不要映射单个文件,而是映射整个目录。

<mvc:resources mapping="/js/**" location="/js/" />

如您所见,映射属性采用 Ant 路径来匹配多个文件和目录。

有关详细信息,请参阅 http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/mvc.html#mvc-config-static-resources

关于java - Spring MVC :resources needs to map to the same filename?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17631881/

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