JAVA-1529: Spring MVC @PathVariable with a dot (.) gets truncated

This commit is contained in:
Krzysiek
2020-05-05 22:21:38 +02:00
parent dba76dd80a
commit 76b1b7a967
4 changed files with 9 additions and 7 deletions

View File

@@ -1,17 +0,0 @@
package com.baeldung.spring.web.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
public class CustomWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
@Override
protected PathMatchConfigurer getPathMatchConfigurer() {
PathMatchConfigurer pathMatchConfigurer = super.getPathMatchConfigurer();
pathMatchConfigurer.setUseSuffixPatternMatch(false);
return pathMatchConfigurer;
}
}

View File

@@ -1,30 +0,0 @@
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;
}
}