J'écris une application de service RESTful dans Java EE 6. J'ai rencontré une difficulté lors de la définition de la méthode de service HTTP GET qui utilise l'annotation @FormParam.Le service Java RESTful erreur sur l'annotation @FormParam
Technologies que j'utilise:
- Eclipse EE Kepler IDE
- JDK v7
- Glassfish 3 (basé sur Java 6)
- Jersey (partie de Glassfish)
Java:
@GET
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
@Path("/getFromForm")
public String getFromForm(@FormParam("input") String input){
log.log(Level.INFO, "Invoked getFromForm");
String html = "<html> <body>"
+"<center><h1> "+input+"</h1></center>"
+"</body></html>";
return html;
}
JSP:
<form action="/RESTfulServiceDrill/rest/v6/html/getFromForm" method="get"
enctype="application/x-www-form-urlencoded">
<label> Add message: </label>
<input type="text" name="input"/>
<input type="submit" value="OK"/>
<input type="reset" value="clear"/>
</form>
Exception:
java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
Toutes les idées que le coupable est?
Très bon point; c'est la bonne réponse – ucas