I cannot access Robots.txt in Spring -MVC

I am trying to provide access to robots.txt in Spring -MVC. To test the code, I put robots.txt in WebContent , Root and WEB-INF , but I cannot access them.

I have already applied the answers to these questions 1 , 2 , 3 to no avail.

Mycode

 <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:resources mapping="/robots.txt" location="/robots.txt" order="0" /> <mvc:annotation-driven /> 
+2
source share
1 answer

This works for me:

Put robots.txt right below the webapp

In mvc-dispatcher-servlet.xml there is:

<mvc:default-servlet-handler/>

<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/web-resources/" />

Use maven to create your war

+2
source

Source: https://habr.com/ru/post/921994/


All Articles