如何在带有注释映射的Spring MVC中使用不区分大小写的URL [英] How can I have case insensitive URLS in Spring MVC with annotated mappings
本文介绍了如何在带有注释映射的Spring MVC中使用不区分大小写的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的注释映射通过我的spring mvc web应用程序运行良好,但是,它们区分大小写。我找不到让它们不区分大小写的方法。 (我很乐意在Spring MVC中实现这一点,而不是以某种方式重定向流量)
I have annotated mappings working great through my spring mvc web app, however, they are case sensitive. I cannot find a way to make them case insensitive. (I'd love to make this happen within Spring MVC, rather than redirecting traffic somehow)
推荐答案
Spring 4.2将支持不区分大小写的路径匹配。您可以按如下方式对其进行配置:
Spring 4.2 will support case-insensitive path matching. You can configure it as follows:
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
AntPathMatcher matcher = new AntPathMatcher();
matcher.setCaseSensitive(false);
configurer.setPathMatcher(matcher);
}
}
这篇关于如何在带有注释映射的Spring MVC中使用不区分大小写的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文