我已经通过我的 spring mvc web 应用程序很好地注释了映射,但是它们区分大小写。我找不到让它们不区分大小写的方法。 (我希望在 Spring MVC 中实现这一点,而不是以某种方式重定向流量)
最佳答案
Spring 4.2 will support case-insensitive path matching.可以这样配置:
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
AntPathMatcher matcher = new AntPathMatcher();
matcher.setCaseSensitive(false);
configurer.setPathMatcher(matcher);
}
}
关于java - 如何在带有注释映射的 Spring MVC 中使用不区分大小写的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4150039/