Search code examples
javaspring-mvcannotationshttp-request-parameters

Spring params is not working


Annotation with spring params is not working.

@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;
}

I'm using this function for get value in put but it shows 400 Bad Request. Any help?


Solution

  • right ans is this ... and thx to 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;
        }