我在使用Spring MVC 4.這裏是我的控制器代碼:HTTP狀態400 - 需要短參數「分數」是不存在的,Spring MVC的REST
@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;
}
}
我公司採用先進其餘客戶提出這個要求(也試過在同一個郵差):
{"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.
什麼是我在這裏無法檢測到的錯誤。請幫我解決它。
嘗試使用這個'@RequestParam(「分數」)的URL的一部分,而不是一些JSON'而不是 –
@Akash Rajbanshi:是的,我現在嘗試。但仍然是同樣的錯誤。 「所需的短參數」分數「不存在」:( – Chandz
將所有參數的類型更改爲字符串... –