Skip to main content

Enable alwaysUseFullPath with mvc:annotation-driven

mvc:annotation-driven doesnot have alwaysUseFullPath attribute. However, in instances this is needed, adding the following bean BEFORE mvc:annnotation-driven tag will set up the alwaysUseFullPath correctly

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" id="handlerMapping">
        <property name="alwaysUseFullPath" value="true">
</property></bean>

So the fuller xml should like this
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" id="handlerMapping">
        <property name="alwaysUseFullPath" value="true">
    </property></bean>
 <mvc:annotation-driven>
  <mvc:message-converters>
   <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    <property name="objectMapper" ref="jacksonObjectMapper">
    <property name="supportedMediaTypes" value="application/json">
   </property></property></bean>
  </mvc:message-converters>
 </mvc:annotation-driven>


    <mvc:interceptors>
        <bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramname="lang">
        <bean class="org.springframework.web.servlet.mvc.WebContentInterceptor" id="webContentInterceptor" p:alwaysusefullpath="true" p:cacheseconds="0">
            <property name="cacheMappings">
                <props>
                    <prop key="/api/**">0</prop>
                </props>
            </property>
        </bean>
    </bean></bean></mvc:interceptors>