@Requestparam:无法获取第二个输入的请求参数

Min*_*inh 1 java spring curl spring-mvc

我正在尝试创建简单的REST请求处理程序,如下所示:

@RequestMapping(value = "test", method = RequestMethod.GET)
public String test(@RequestParam(name = "test", required = false) String test, 
                   @RequestParam(name ="number", required = false) Long number) {

    return new StringBuilder(test).append(" ").append(number).toString();
}
Run Code Online (Sandbox Code Playgroud)

但是当我通过CURL测试时:

curl http://localhost:8080/test?test=abc&number=2016
Run Code Online (Sandbox Code Playgroud)

输出结果如下:

abc null
Run Code Online (Sandbox Code Playgroud)

怎么了 这是我的错误还是Spring错误?我正在使用Spring Boot 1.4.0(可能是最新版本)。curl版本是7.43.0(64位)。

mei*_*ier 5

希望这是解决方案,而不是错误的假设:

如果您确实输入:

curl http://localhost:8080/test?test=abc&number=2016

您的卷发过程

curl http://localhost:8080/test?test=abc

由于将会执行并在后台发送&

尝试:

curl 'http://localhost:8080/test?test=abc&number=2016'