Show pageBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Handling the Trailing Slash in URL ====== For now, if you use @RequestMapping, @GetMapping, @PostMapping, ... you will see that if you accidentally added a trailing slash "/" in the URL, you will get a 404 HTTP error. To handling this problem, we need to add a path matching configurer. - Write a WebConfiguration class with @Configuration annotation that implements WebMvcConfigurer. - @Override that method ''public void configurePathMatch(PathMatchConfigurer configurer){...}'' - The method looks like:<code> @Override public void configurePathMatch(PathMatchConfigurer configurer){ configurer.setUseTrailingSlashMatch(true); } </code> To manipulate the URL, you can chain this configurer with ''setPathHelper(...)'', or ''setUrlPathHelper(...)'' with your own implementation of ''PathMatcher'' or ''UrlPathHelper''. springboot/handling_the_trailing_slash_in_url.txt Last modified: 2020/06/01 14:51by chongtin