Spring MVC @PathVariable dot (.) get truncated
This commit is contained in:
parent
57a4f160aa
commit
0c81d77e1b
|
@ -0,0 +1,17 @@
|
|||
package com.baeldung.spring.web.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
@Configuration
|
||||
public class CustomWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
|
||||
|
||||
@Bean
|
||||
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
|
||||
RequestMappingHandlerMapping handlerMapping = super.requestMappingHandlerMapping();
|
||||
handlerMapping.setUseSuffixPatternMatch(false);
|
||||
return handlerMapping;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.baeldung.web.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@RequestMapping("/site")
|
||||
public class SiteController {
|
||||
|
||||
@RequestMapping(value = "/{firstValue}/{secondValue}", method = RequestMethod.GET)
|
||||
public String requestWithError(@PathVariable("firstValue") String firstValue,
|
||||
@PathVariable("secondValue") String secondValue) {
|
||||
|
||||
return firstValue + " - " + secondValue;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{firstValue}/{secondValue:.+}", method = RequestMethod.GET)
|
||||
public String requestWithRegex(@PathVariable("firstValue") String firstValue,
|
||||
@PathVariable("secondValue") String secondValue) {
|
||||
|
||||
return firstValue + " - " + secondValue;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{firstValue}/{secondValue}/", method = RequestMethod.GET)
|
||||
public String requestWithSlash(@PathVariable("firstValue") String firstValue,
|
||||
@PathVariable("secondValue") String secondValue) {
|
||||
|
||||
return firstValue + " - " + secondValue;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue