我无法在Spring-MVC中访问Robots.txt


问题内容

我试图robots.txt在Spring-
MVC中提供访问权限。为了测试代码,我把robots.txtWebContentRootWEB-INF,但我不能访问任何人。

我已经应用了这些问题的答案1,2,3无济于事。

我的密码

<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建立战争