C#项目转Java项目的时候,出现的一些问题,由于C#没有区分大小写路由,前端页面也不够规范,同一个页面,有的是大写,有的是小写,这个在java里面就必须进行javaconfig的配置处理
具体需要添加一个统一的类来路由到页面
package com.ly.wanle.admin.web.config; import org.springframework.util.AntPathMatcher;//需要特别注意这一行注释的问题 import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; @Configuration public class WebConfig extends WebMvcConfigurationSupport { @Override public void configurePathMatch(PathMatchConfigurer configurer) { AntPathMatcher matcher = new AntPathMatcher(); matcher.setCaseSensitive(false); configurer.setPathMatcher(matcher); } }
添加这个注释之后,就能大小写路由兼容了。