java - case insensitive mapping for Spring MVC @RequestMapping annotations -


possible duplicate:
how can have case insensitive urls in spring mvc annotated mappings

i have controller having multiple @requestmapping annotations in it.

@controller public class signupcontroller {   @requestmapping("signup")  public string showsignup() throws exception {     return "somejsp";  }   @requestmapping("fullsignup")  public string showfullsignup() throws exception {     return "anotherjsp";  }   @requestmapping("signup/createaccount")  public string createaccount() throws exception {     return "anyjsp";  } } 

how can map these @requestmapping case insensitive. i.e. if use "/fullsignup" or "/fullsignup" should "anotherjsp". not happening right now. "/fullsignup" working fine.

i've tried extending requestmappinghandlermapping no success. i've tried antpathmatcher guy mentioned there question on forum not working @requestmapping annotation.

debugging console enter image description here

output console when server up.

enter image description here

i've added 2 images shows problem. i've tried both solutions mentioned below. console says mapped lowercased urls when request access method lowercase url shows original map values stored stilled contained mixcase urls.

one of approaches in how can have case insensitive urls in spring mvc annotated mappings works perfectly. tried combinations of @requestmapping @ level of controller , request methods , has worked cleanly, reproducing here spring 3.1.2:

the caseinsensitivepathmatcher:

import java.util.map;  import org.springframework.util.antpathmatcher;  public class caseinsensitivepathmatcher extends antpathmatcher {     @override     protected boolean domatch(string pattern, string path, boolean fullmatch, map<string, string> uritemplatevariables) {         return super.domatch(pattern.tolowercase(), path.tolowercase(), fullmatch, uritemplatevariables);     } } 

registering path matcher spring mvc, remove <mvc:annotation-driven/> annotation, , replace following, configure appropriately:

<bean name="handleradapter" class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter">     <property name="webbindinginitializer">         <bean class="org.springframework.web.bind.support.configurablewebbindinginitializer">             <property name="conversionservice" ref="conversionservice"></property>             <property name="validator">                 <bean class="org.springframework.validation.beanvalidation.localvalidatorfactorybean">                     <property name="providerclass" value="org.hibernate.validator.hibernatevalidator"></property>                 </bean>             </property>         </bean>     </property>     <property name="messageconverters">         <list>             <ref bean="bytearrayconverter"/>             <ref bean="jaxbconverter"/>             <ref bean="jsonconverter"/>             <bean class="org.springframework.http.converter.stringhttpmessageconverter"></bean>             <bean class="org.springframework.http.converter.resourcehttpmessageconverter"></bean>             <bean class="org.springframework.http.converter.xml.sourcehttpmessageconverter"></bean>             <bean class="org.springframework.http.converter.xml.xmlawareformhttpmessageconverter"></bean>         </list>     </property> </bean> <bean name="bytearrayconverter" class="org.springframework.http.converter.bytearrayhttpmessageconverter"></bean> <bean name="jaxbconverter" class="org.springframework.http.converter.xml.jaxb2rootelementhttpmessageconverter"></bean> <bean name="jsonconverter" class="org.springframework.http.converter.json.mappingjackson2httpmessageconverter"></bean> <bean name="caseinsensitivepathmatcher" class="org.bk.lmt.web.spring.caseinsensitivepathmatcher"/> <bean name="handlermapping" class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandlermapping">     <property name="pathmatcher" ref="caseinsensitivepathmatcher"></property> </bean> 

or more , cleanly using @configuration:

@configuration @componentscan(basepackages="org.bk.webtestuuid") public class webconfiguration extends webmvcconfigurationsupport{      @bean     public pathmatcher pathmatcher(){         return new caseinsensitivepathmatcher();     }     @bean     public requestmappinghandlermapping requestmappinghandlermapping() {         requestmappinghandlermapping handlermapping = new requestmappinghandlermapping();         handlermapping.setorder(0);         handlermapping.setinterceptors(getinterceptors());         handlermapping.setpathmatcher(pathmatcher());         return handlermapping;     } } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -