Java 如何防止Spring MVC参数在“之后被截断”&引用;
我正在从事一个web项目,并使用SpringMVC3.1.1。SpringMVC用于服务REST服务(使用URL注释) 关于我的问题: 假设我的服务url路径为:Java 如何防止Spring MVC参数在“之后被截断”&引用;,java,spring-mvc,Java,Spring Mvc,我正在从事一个web项目,并使用SpringMVC3.1.1。SpringMVC用于服务REST服务(使用URL注释) 关于我的问题: 假设我的服务url路径为: http://localhost:8080/MyAppName/services/meteo/queryWeatherData/lon/39.1123/lat/39.3123 我的控制器方法如下: @RequestMapping(method = RequestMethod.GET, value = {"/queryWeatherD
http://localhost:8080/MyAppName/services/meteo/queryWeatherData/lon/39.1123/lat/39.3123
我的控制器方法如下:
@RequestMapping(method = RequestMethod.GET, value = {"/queryWeatherData/lon/{lon}/lat/{lat}"})
public void queryWeatherData(
final @PathVariable("lon") float lon,
final @PathVariable("lat") float lat,
final HttpServletResponse response, final HttpServletRequest request) {
//
// DO STUFF and prepare response
//
}
我看到第二个参数(lat)在“.”之后被截断,所以我看到服务器端的值是39.0
我尝试在app-context.xml中声明一个DefaultAnnotationHandlerMapping bean,并将其UseDefaultSuffExpattern设置为false,但没有成功
如何解决此问题?使用
UseDefaultSuffExpattern=false
声明DefaultAnnotationHandlerMapping
bean是正确的方法,但请确保您也注释掉:
请参阅:尝试在末尾添加斜杠,即
http://localhost:8080/MyAppName/services/meteo/queryWeatherData/lon/39.1123/lat/39.3123/
。如果这改变了它,它可能看起来像文件扩展名一样.3123
。可能的重复我知道可能存在重复的问题,但该问题的说明不适用于meI尝试使用UseDefaultSulfExpattern=false
声明DefaultAnnotationHandlerMapping
bean,但我没有注释掉
事实就是这样。非常感谢你