java - 如何在带有注释映射的 Spring MVC 中使用不区分大小写的 URL

标签 java spring spring-mvc mapping case-insensitive

我已经通过我的 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/

相关文章:

java - Spring Boot init.d not 未运行(未找到进程)

java - Jmockit 模拟抽象类

Java 小程序在 Chrome 中不可见

java - ResultSet 不是用于INSERT 查询?错误消息 : Type mismatch: cannot convert from int to String

java - Spring Security 登录返回 404

java - Spring MVC 验证错误消息

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name

java - 创建访客 session

java - 无需安装 SQL Server 即可通过 JDBC 连接到远程服务器

java - Spring batch Input resource must exist (reader is in 'strict' mode)错误