File tree Expand file tree Collapse file tree
spring-mvc-java/src/main/java/com/baeldung Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .baeldung .spring .web .config ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .Configuration ;
5+ import org .springframework .web .servlet .config .annotation .WebMvcConfigurationSupport ;
6+ import org .springframework .web .servlet .mvc .method .annotation .RequestMappingHandlerMapping ;
7+
8+ @ Configuration
9+ public class CustomWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
10+
11+ @ Bean
12+ public RequestMappingHandlerMapping requestMappingHandlerMapping () {
13+ RequestMappingHandlerMapping handlerMapping = super .requestMappingHandlerMapping ();
14+ handlerMapping .setUseSuffixPatternMatch (false );
15+ return handlerMapping ;
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .web .controller ;
2+
3+ import org .springframework .web .bind .annotation .PathVariable ;
4+ import org .springframework .web .bind .annotation .RequestMapping ;
5+ import org .springframework .web .bind .annotation .RequestMethod ;
6+
7+ @ RequestMapping ("/site" )
8+ public class SiteController {
9+
10+ @ RequestMapping (value = "/{firstValue}/{secondValue}" , method = RequestMethod .GET )
11+ public String requestWithError (@ PathVariable ("firstValue" ) String firstValue ,
12+ @ PathVariable ("secondValue" ) String secondValue ) {
13+
14+ return firstValue + " - " + secondValue ;
15+ }
16+
17+ @ RequestMapping (value = "/{firstValue}/{secondValue:.+}" , method = RequestMethod .GET )
18+ public String requestWithRegex (@ PathVariable ("firstValue" ) String firstValue ,
19+ @ PathVariable ("secondValue" ) String secondValue ) {
20+
21+ return firstValue + " - " + secondValue ;
22+ }
23+
24+ @ RequestMapping (value = "/{firstValue}/{secondValue}/" , method = RequestMethod .GET )
25+ public String requestWithSlash (@ PathVariable ("firstValue" ) String firstValue ,
26+ @ PathVariable ("secondValue" ) String secondValue ) {
27+
28+ return firstValue + " - " + secondValue ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments