0

Have a AngularJS service calling the http Get and passing user object as an argument.

 $http.get(urls.USER_SERVICE_API_LOGIN + user)
                    .then(...

And my Spring controller is as below-

@RequestMapping(value = "/login/{user}", method = RequestMethod.GET)
    public ResponseEntity<?> findUserByUserNameAndPasswordForLogin(@PathVariable(value = "user") User user) { \\\ methos definition}

so getting exception when calling Spring controller saying "Failed to convert value of type 'java.lang.String' to required type 'model.User'" where user is my Java object and i understand AngularJS is trying to pass everything as a String. so what is the solution for this please?

Developer1001
  • 63
  • 1
  • 8
  • You won't be able to do this using HTTP GET method, either you need to use POST or PUT for this. – K.D Oct 17 '19 at 06:51
  • How could a whole object be part of the path of a URL? A request sending a password should never use GET. You don't want the password to be part of the URL and be stored in logs for anyone to see. Use a POST. – JB Nizet Oct 17 '19 at 07:03
  • so if i want to pass userName and password only how to pass that - $http.get(urls.USER_SERVICE_API_LOGIN + userName,password), will this work. – Developer1001 Oct 17 '19 at 07:08

0 Answers0