Java server side cannot process requests of contentType "www-form-urlencoded" from Editor Ajax call

Java server side cannot process requests of contentType "www-form-urlencoded" from Editor Ajax call

ZhenZhen Posts: 2Questions: 1Answers: 0

Editor's Ajax call always sends request payload of contentType "www-form-urlencoded".
This contentType cannot be changed by setting its Ajax options "contentType" to "application/json" and "dataType" to "json".
I find that Editor's Ajax call with a bit complicated request data cannot be processed on Java server side (Spring REST & MVC)
due to the error in object mapping.
How to resolve this problem?

Answers

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    Is sending the data as raw JSON an option? Most server-side environments have that ability and I assume Spring is no exception. You can use:

    ajax: {
      url: ...,
      data: function ( d ) {
        return JSON.stringify( d );
      }
    }
    

    in Editor's configuration to do that.

    Allan

This discussion has been closed.