Ich schreibe eine RESTful Service-App in Java EE 6. Ich habe eine Schwierigkeit bei der Definition HTTP GET-Service-Methode, die die @ FormParam Annotation verwendet.Java RESTful Service Fehler auf @FormParam Annotation
Technologies, die ich benutze:
- Eclipse-EE Kepler IDE
- JDK v7
- Glassfish 3 (basierend auf Java 6)
- Jersey (Teil von 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>
Ausnahme:
java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
Irgendwelche Ideen, was der Täter ist?
Sehr guter Punkt erfasst; es ist die richtige Antwort – ucas