0 Replies Latest reply on Oct 14, 2014 3:54 AM by Ing

    Problems with UTF-8 ( using @MultipartForm )

    Ing Newbie



      I have an application using RESTeasy, and my problems is - I do not get the ÖÄÅ-characters right.

      I am debugging the class, so the problem is my RESTeasy-code.


      My dependecies in maven look like this.

        1. <dependency>
        2. <groupId>org.jboss.resteasy</groupId>
        3. <artifactId>resteasy-jaxb-provider</artifactId>
        4. <version>3.0.6.Final</version>
        5. </dependency>
        6. <dependency>
        7. <groupId>org.jboss.resteasy</groupId>
        8. <artifactId>resteasy-multipart-provider</artifactId>
        9. <version>2.3.1.GA</version>
        10. </dependency>
        11. <dependency>

        12. <groupId>org.jboss.resteasy</groupId>

        13. <artifactId>resteasy-jackson-provider</artifactId>

        14. <version>3.0.5.Final</version>






      One of my classes has the following :

      public class FileUploadForm implements Serializable {

          private static final long serialVersionUID = 1L;


          private String mediaUUID;



          private byte[] fileData;


          private String owner;


      And my RESTful-service has the following :


      1.      @POST
      2.     @Path("/upload-file")
      3.     @Consumes(MediaType.MULTIPART_FORM_DATA)
      4.     @Produces("text/plain")
      5.     public Response createNewFile(@MultipartForm FileUploadForm form) throws IOException {
      6.           String owner = form.getOwner()


      If I send in "Owner" with the name "Özz" then I get some gibberish as in "?zz" when debugging line 6.


      Following some leads when googling -> RESTEasy JAX-RS

      I create the following :

      @Provider @ServerInterceptor public class ContentTypeSetterPreProcessorInterceptor implements PreProcessInterceptor {  public ServerResponse

      preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException { request.setAttribute(InputPart.DEFAULT_CHARSET_PROPERTY, "UTF-8"); return null; }  }


      Then I decorate my createNewFile with 'ContentTypeSetterPreProcessorInterceptor' class as in:






          public Response createNewFile(@MultipartForm FileUploadForm form) throws IOException


      I am calling this restful-service from the following jsp-file:

      <form action="media/upload-file" method="post" enctype="multipart/form-data"



      And when debugging I can see that I am in the preProcess-method.

      But that does not change a thing ....


      Is there any way, a good way, to work-around this problem.

      I have ofcourse more than the 'owner' that I am concerned about.


      Hope that you can give me a hand.


      regards, i