MissingServletRequestParameterException:requird参数不存在

时间:2015-08-03 10:07:02

标签: java spring spring-mvc

@RequestMapping(value = "/connect{accountDeviceId}", method = RequestMethod.GET)
public @ResponseBody
String showCompleteAuthorizat(HttpServletRequest request,
        HttpServletResponse response,
        @RequestParam("accountDeviceId") int accountDeviceId) throws Exception {

我收到此错误

org.springframework.web.bind.MissingServletRequestParameterException: Required int parameter 'accountDeviceId' is not present

这是调用上述api

的网址
http://localhost:8080/gch-restful/fitbit/connect29?oauth_token=b1e939450e745664ce4bbbc194b4ed47f&oauth_verifier=9dc1045654dc775d2347ae2963d5ae878c

我刚接触春天并基本上学习它,请告诉我这里我做错了什么。

此致

1 个答案:

答案 0 :(得分:2)

您应该使用@PathVariable(value="accountDeviceId")代替@RequestParam("accountDeviceId"),以便从网址获取变量。