In Spring 6 MVC, trailing slashes in URLs are not automatically handled
/*Only handle localhost:8080/hello, access /hello/ will give 404 */
@GetMapping("/hello")
public String hello() {
return "hello";
}
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseTrailingSlashMatch(true);
}
}
本文由 Ivan Dong 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jun 25, 2023 at 03:31 am