0
Java EE 6でRESTfulサービスアプリケーションを作成しています。@FormParamアノテーションを使用するHTTP GETサービスメソッドを定義する際に問題が発生しました。私が使用@FormParamアノテーションのJava RESTfulサービスエラー
技術:
- のEclipse EEケプラーIDE
- JDK v7の
- Glassfishの3
- ジャージー(Glassfishのの一部)
(Javaの6に基づきます) 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