- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Description
Sam Brannen opened SPR-6483 and commented
Given the following @MVC controllers...
@Controller
@RequestMapping(value = "/{id}")
public class OrderDetailsController {
	@RequestMapping(method = GET)
	public String display(@PathVariable("id") Long id) {
		// ...
	}
}
@Controller
@RequestMapping("/new*")
public class NewOrderController {
	@RequestMapping(method = GET)
	public final String edit() {
		// ...
	}
}
...the following URL worked with Spring 3.0.0.RC2:
http://localhost:8080/order/new
After upgrading from RC2 to RC3, I get the following exception when attempting to access the above URL:
org.springframework.core.convert.ConversionFailedException: Unable to convert value new
from type [java.lang.String] to type [java.lang.Long]; reason = 'Unable to convert value
new from type [java.lang.String] to type [java.lang.Long]; reason = 'new'; nested
exception is java.text.ParseException: new'; nested exception is
org.springframework.core.convert.ConversionFailedException: Unable to convert value new
from type [java.lang.String] to type [java.lang.Long; reason = 'new'; nested exception
is java.text.ParseException: new
        at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:40)
        at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:130)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:199)
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104)
        at org.springframework.beans.SimpleTypeConverter.convertIfNecessary(SimpleTypeConverter.java:47)
        at org.springframework.validation.DataBinder.convertIfNecessary(DataBinder.java:526)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolvePathVariable(HandlerMethodInvoker.java:618)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:292)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:164)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:385)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:373)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
...
The only way to access the "new" page with the "/new*" RequestMapping is by adding a bogus file extension such as ".htm" (FYI: simply appending a dot "." suffices), for example: http://localhost:8080/order/new.htm or http://localhost:8080/order/new.
By using a "/new/*" RequestMapping instead, the "new" page can only be accessed by adding a bogus subpath such as "/x" (FYI: simply appending a slash "/" does not suffice), for example: http://localhost:8080/order/new/x
Changing the RequestMapping for the OrderDetailsController from "/{id}" to "/{id}/" almost effects the desired reseults; however, this mapping requires that URLs such as http://localhost:8080/order/10000 be appended with a trailing slash "/" which is undesirable.
In the end, using a RequestMapping of "/{id}**" for the OrderDetailsController achieves the desired results (i.e., same behavior as with Spring 3.0.0.RC2). Thus the question remains:
Was this change intentional?
Or should the mappings from RC2 continue to work with RC3 and beyond?
Affects: 3.0 RC3
Issue Links:
- Url suffix after dot is omitted [SPR-6518] #11184 Url suffix after dot is omitted