I have a login form with two values name and password. I pass this value as in my rest service. I get this value in my rest service using FormParam
annotation. But, my requirement is to get that values as a class. I tried below methodology. But it's not work and shows the compile time error:
@Form cannot be resolved to a type.
@POST
@Path("login")
@Produces(MediaType.TEXT_PLAIN)
public String login(@Form User form) {
return "Logged with " + form.email + " " + form.password;
}
public class User {
@FormParam("email")
private String email;
@FormParam("password")
private String password;
}
My form is
<form method="POST" action="rest/login">
Email Address: <input type="text" name="email">
<br>
Password: <input type="text" name="password">
<input type="submit">
</form>
How to receive form value as object?