我正在尝试在 Spring-MVC 中授予对 robots.txt
的访问权限。为了测试代码,我将 robots.txt
放入 WebContent
、Root
和 WEB-INF
但我无法访问给他们中的任何一个。
MyCode
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/robots.txt" location="/robots.txt" order="0" />
<mvc:annotation-driven />
最佳答案
这对我有用:
放robots.txt
直属webapp
在mvc-dispatcher-servlet.xml
有:
<mvc:default-servlet-handler/>
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/web-resources/" />
使用maven构建你的war
关于java - 我无法在 Spring-MVC 中访问 Robots.txt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32302465/