I have an MVC Spring project (4.1.6.RELEASE) with a controller that maps to /home , but my problem is that it is also called for paths like /home.html or /home.do
My configuration:
web.xml:
<servlet> <servlet-name>main</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>main</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
main servlet.xml:
<mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean>
HomeController.java:
@Controller @RequestMapping({"/", "/home"}) public class HomeController { @RequestMapping(method = RequestMethod.GET) public String doGet(Model model) {
As suggested in similar questions:
I tried to add the following configurations:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="useDefaultSuffixPattern" value="false" /> </bean>
and
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"> <property name="useSuffixPatternMatch" value="false" /> <property name="useRegisteredSuffixPatternMatch" value="false" /> </bean>
but without success.
When I debug a DispatcherServlet , I see that the RequestMappingHandlerMapping and DefaultAnnotationHandlerMapping did not set the above comments to the false properties.

It seems like a simple configuration should do this, but I am missing something that I cannot recognize.
How to configure DispatcherServlet to avoid file extensions in displayed paths?
Thanks in advance.
source share