使用spring params的注释不起作用。

@RequestMapping(value = "/login", method = RequestMethod.PUT)
public @ResponseBody ResponseMsg login(@RequestParam String userName, @RequestParam String password )
{
    ResponseMsg responseMsg = CommonUtils.checkParam(userName, password);

    if(responseMsg.getStatus().equalsIgnoreCase("True"))
    {
        responseMsg =  userService.login(userName, password);
    }
    return responseMsg;
}


我正在使用此功能来获取价值,但它显示400错误请求。有什么帮助吗?

最佳答案

正确的答案是这个...对OQJF来说很重要

@RequestMapping(value = "/login", method = RequestMethod.GET)
    public @ResponseBody ResponseMsg login(@RequestHeader(value="username", required=false) String userName,
            @RequestHeader(value="password", required=false) String password ) {

        ResponseMsg responseMsg = CommonUtils.checkParam(userName, password);
        if(responseMsg.getStatus().equalsIgnoreCase("True"))
            responseMsg =  userService.login(userName, password);
        return responseMsg;
    }

07-26 03:02