HTTP 状态 400 - 必需的短参数 'score' 不存在,Spring MVC REST
HTTP Status 400 - Required short parameter 'score' is not present, Spring MVC REST
我正在使用 Spring MVC 4。这是我的控制器代码:
@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;
}
}
我正在使用高级休息客户端发出此请求(也在 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 的一部分,而不是您 post
的某些 JSON
我正在使用 Spring MVC 4。这是我的控制器代码:
@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;
}
}
我正在使用高级休息客户端发出此请求(也在 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 的一部分,而不是您 post
的某些 JSON