Reputation: 1771
I'm currently working on an AngularJS project and I'm calling some rest services using content-type "application/x-www-form-urlencoded;".
On server side I use Jersey in version 2.0. This is my maven dependency.
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.0</version>
</dependency>
Everthing work fine on Chrome and IE7. My problem is Firefox who add mystically "charset=UTF-8" in the content type.
I made some test and if I use POSTMAN and set "application/x-www-form-urlencoded; charset=UTF-8" in the content type, Jersey has null in all FormParam parameters
This is the header of my method in java
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("movements/")
public Response movements(
@FormParam("COMPTE_NO") String COMPTE_NO,
@FormParam("COMPTE_BIDULE") String COMPTE_BIDULE,
@FormParam("COMPTE_MACHIN") String COMPTE_MACHIN,
I tried with this headers
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("movements/")
@Consumes({MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8",
MediaType.APPLICATION_FORM_URLENCODED + "; charset=UTF-8",
MediaType.APPLICATION_FORM_URLENCODED})
public Response movements(
@FormParam("COMPTE_NO") String COMPTE_NO,
@FormParam("COMPTE_BIDULE") String COMPTE_BIDULE,
@FormParam("COMPTE_MACHIN") String COMPTE_MACHIN,
And I had exactly the same problem. Do you have an idea ? Thanks in advance.
Upvotes: 0
Views: 4863
Reputation: 1771
This question is a duplication. A response can be found on Jersey and @FormParam not working when charset is specified in the Content-Type
Jersey ticket and filter has a workaround can be found on the ticket
Upvotes: 2