How enable JSONP in RESTEasy?

前端 未结 5 1738
孤城傲影
孤城傲影 2020-12-16 18:15

Title say about my issue. I need wrap DTO in to a javascript method callback. Currently I return on request JSON. But problem with using this in Ajax because I send GET to o

5条回答
  •  星月不相逢
    2020-12-16 19:08

    To follow on from @talawahdotnet, I'm using RestEasy 3.0.9.Final and there is support for JSONP, once enabled, any request with a "callback" query parameter will be wrapped as JSONP. I'm using JBoss so the full docs are here for other containers. Here's the steps I had to do:

    1. In your web.xml add:

      
          resteasy.providers
          org.jboss.resteasy.plugins.providers.jackson.JacksonJsonpInterceptor
      
      
    2. Make sure you have a WEB-INF/jboss-deployment-structure.xml with:

      
          
              
                  
              
          
      
      
    3. Make sure you have a resteasy-jackson-provider dependency in your pom.xml, something like:

      
          org.jboss.resteasy
          resteasy-jackson-provider
          provided
      
      

提交回复
热议问题