0
我在Java EE 6中编写了一个RESTful服务应用程序。我在定义使用@FormParam注释的HTTP GET服务方法时遇到了困难。@FormParam注释上的Java RESTful服务错误
技术,我用:
- 的Eclipse EE开普勒IDE
- JDK V7
- Glassfish的3(基于Java 6)
- 泽西(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>
例外:
java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
任何想法的罪魁祸首是什么?
非常好的一点;这是正确的答案 – ucas