How to change spring request mapping to disallow url pattern with suffix -


i using spring mvc 3.2 , deploying in apache tomcat 1.7x. login url /web/login using url /web/login.abc abc can text including space.

in both cases returning same resource avoid , return http code 404.

tried adding below in web.xml did not help

`<beans:bean class="org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping">     <beans:property name="usedefaultsuffixpattern" value="false" /> </beans:bean>` 

this config depends on version you're using you've omitted in question. since spring 4.0.3 suffix properties set on pathmatchconfigurer class. per spring doc config should under mvc:annotation-driven, e.g.

  <mvc:annotation-driven>     <mvc:path-matching suffix-pattern="false" />   </mvc:annotation-driven> 

as explained in docs

whether use suffix pattern match (".*") when matching patterns requests. if enabled method mapped "/users" matches "/users.*". default value true.

for spring 3.2 should be

  <beans:bean id="handlermapping"  class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandlermapping">       <beans:property name="usesuffixpatternmatch" value="false"/>   </beans:bean>` 

also, if you're using mvc:annotation-driven element in config, take note of biju's answer question how restrict route extensions in @requestmapping paths spring mvc controllers?


Comments