【发布时间】:2015-08-31 00:18:40
【问题描述】:
我正在尝试在 Spring-MVC 中授予对 robots.txt 的访问权限。为了测试代码,我将robots.txt 放入WebContent、Root 和WEB-INF,但我无法访问其中任何一个。
我的代码
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/robots.txt" location="/robots.txt" order="0" />
<mvc:annotation-driven />
【问题讨论】:
-
放入
webapp你有Spring Security设置吗? -
@NeilMcGuigan 不,我没有那个设置。
-
@NeilMcGuigan 如果我把它放在 webapp 中,如何访问它?我需要在我的 Spring 应用程序或 Tomcat 中配置什么吗?我的根文件夹中有一个 test.jsp 文件,我可以访问但不能访问这个 robots.txt 文件。
标签: java spring spring-mvc web-hosting robots.txt