I have following rest endpoint in spring boot application:
@RequestMapping(method = RequestMethod.POST, value = "/sign-in")
public Client signIn(@RequestParam String username, @RequestParam String password, HttpServletRequest request) {
Client client = authService.signIn(username, password);
return client;
}
I want accept data as application/json.
Is it possible to do this WITHOUT creating class for this like this?:
public class LoginModel {
private String username;
private String password;
...
}
Also, without argument of type Map in signIn method
I need to accept application/json with this signature:
public Client signIn(@RequestParam String username, @RequestParam String password)
Is it possible?
No. I don't think it's possible.
You need to create the intermediary Login
object.
@RequestParam
mandates you have a request param.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.