繁体   English   中英

HTTP状态400-所需的简短参数'score'不存在,Spring MVC REST

[英]HTTP Status 400 - Required short parameter 'score' is not present, Spring MVC REST

我正在使用Spring MVC4。这是我的控制器代码:

@RestController
public class NewValueController 
{
   @RequestMapping(value="/receiveUpdatedScore",method=RequestMethod.POST,produces={"application/json"})
   public NewValue receiveUpdateScore(@RequestParam(value="score") short score,
                               @RequestParam(value="user_id") String user_id,
                               @RequestParam(value="device_model") String device_model,
                               @RequestParam(value="api_key") String api_key,
                               @RequestParam(value="gen_t") long gen_t,
                               Model model)
  {
    int newScore = (int) score;
    NewValue algorithm=new NewValue();
    NewValue newvalue=algorithm.getNextValue(newScore);
    return newvalue;
  }
}

我正在使用高级Rest客户端发出此请求(在Postman中也尝试过):

{"score":"50","user_id":"zyz","device_model":"xiami","api_key":"sasa5454","gen_t":"545666"}

但我收到以下错误

错误:

HTTP Status 400 - Required Short parameter 'score' is not present

message: Required Short parameter 'score' is not present

description: The request sent by the client was syntactically incorrect.

我在这里找不到的错误是什么。 请帮我解决。

我认为这是因为期望分数是URL的一部分,而不是您发布的JSON

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM