Merge pull request #4064 from fscorro/BAEL-1685
Spring MVC @PathVariable dot (.) get truncated
This commit is contained in:
commit
5f5d83472f
|
@ -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