A Jersey POJOMapping Example in Mapping Form Parameters
In Java Servlet circumstance, we usually harvest the form parameters by using request.getParameter(“FORM_FIELD_NAME”) syntax. Now we can do it more elegant while enabling Jsersey’s POJOMapping features. The following example demonstrates the account registration scenario. Here we have a Account class:
As shown in above code, we can read value from input steam into custom class (i.e., Account class) then continue doing the following business logic. However, you may encounter the Unsupported Media Type status code (415) while using the static HTML form post method. This is because we identify the service-consume-type is JSON.
So we get correct response and mapping object while the corresponding way. Note that the differences in Content-Type and Request Payload parts.