如何在带有注释映射的 Spring MVC 中使用不区分大小写的 URL [英] How can I have case insensitive URLS in Spring MVC with annotated mappings

查看:29
本文介绍了如何在带有注释映射的 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 将支持不区分大小写的路径匹配. 可以如下配置:

@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆