以下四个Url可以指向同一个Controller方法
http://localhost:8080/Test
http://localhost:8080/tesT
http://localhost:8080/teSt
http://localhost:8080/test
一、解决方案One(下面的applicationContext.xml配置有些可以简化)
package com.xxx.configuretion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.AntPathMatcher;
import java.util.Map;
/**
* 处理Url大小写问题
*/
public class PathMatcher extends AntPathMatcher {
private final Logger LOGGER = LoggerFactory.getLogger(PathMatcher.class);
@Override
protected boolean doMatch(String pattern, String path, boolean fullMatch, Map<String, String> uriTemplateVariables) {
LOGGER.info(pattern + " -- " + path);
return super.doMatch(pattern.toLowerCase(), path.toLowerCase(), fullMatch, uriTemplateVariables);
}
}
applicationContext.xml:
<bean id="matcher" class="com.xxx.configuretion.PathMatcher"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="pathMatcher" ref="matcher"/>
</bean>
<bean class="org.sp