Using Jersey to read form data

后端 未结 2 1511
失恋的感觉
失恋的感觉 2021-01-05 12:20

I\'m developing a web app where i have a form like that

2条回答
  •  独厮守ぢ
    2021-01-05 13:11

    try this:

    @Path("test")
    @POST
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public String testForm(@FormParam("accept") String accept) {
        return accept;
    }
    

    Multipart is something slightly different, see jersey sample multipart-webapp or see http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html. Your web form is not producing it, so Jersey correctly returns 415 - Unsupported media type, because you don't have any resource which is handling "application/x-www-form-urlencoded" media type.

提交回复
热议问题