How it works...

Let's look at what we did in detail. The configurePathMatch(PathMatchConfigurer configurer) method gives us the ability to set our own behavior in how we want Spring to match the request URL path to the controller parameters:

  • configurer.setUseSuffixPatternMatch(false): This method indicates that we don't want to use the .* suffix, so as to strip the trailing characters after the last dot. This means that Spring parses out the entire 978-1-78528-415-1.1 ISBN as an {isbn} parameter for BookController. So, http://localhost:8080/books/978-1-78528-415-1.1 and http://localhost:8080/books/978-1-78528-415-1 will become different URLs.
  • configurer.setUseTrailingSlashMatch(true): This method indicates that we want to use the trailing / symbol in the URL as a match as if it were not there. This effectively makes http://localhost:8080/books/978-1-78528-415-1 the same as http://localhost:8080/books/978-1-78528-415-1/.

If you want to do further configuration of how the path matching takes place, you can provide your own implementation of PathMatcher and UrlPathHelper, but these would be required in the most extreme and custom-tailored situations and are not generally recommended.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.108.54