Cross-domain request resolution (JSONP, CORS) mentions resolving cross-domain can be used
Jsonp,resteasy Self-jsonp interceptor
First, refer to the method inside the Http://stackoverflow.com/questions/5350924/how-enable-jsonp-in-resteasy:
1. In your Web. XML add:
<context-param> <param-name>resteasy.providers</param-name> <param-value> Org.jboss.resteasy.plugins.providers.jackson.jacksonjsonpinterceptor</param-value></context-param>
2. Make sure a web-inf/jboss-deployment-structure.xml with:
<jboss-deployment-structure> <deployment> <dependencies> <module name= " Org.jboss.resteasy.resteasy-jackson-provider "services=" import "annotations=" true "/> </dependencies > </deployment></jboss-deployment-structure>
3, make sure you has a resteasy-jackson-provider dependency in your pom.xml, something like:
<dependency> <groupId>org.jboss.resteasy</groupId> <artifactId> Resteasy-jackson-provider</artifactid> <scope>provided</scope></dependency>
Second, but Resteasy's documentation mentions the use of:
<dependency> <groupId>org.jboss.resteasy</groupId> <artifactId> resteasy-json-p-provider</artifactid> <version>3.0.9.Final</version> </dependency >
Thirdly, I tried it myself.
1, JSON and JSONP are in the Resteasy-jackson2-provider inside, Pom.xml:
<dependency><groupId>org.jboss.resteasy</groupId><artifactId> Resteasy-jackson2-provider</artifactid><version>3.0.9.final</version></dependency>
2. Web. xml:
<context-param><param-name>resteasy.providers</param-name><param-value> Org.jboss.resteasy.plugins.providers.jackson.jackson2jsonpinterceptor</param-value></context-param >
But there is still a problem and the last use
GET HTTP://LOCALHOST:8080/RESTEASY_02_JSONP/JSON/PRODUCT/GET?CALLBACK=AAA
return: aaa ({"Name": "IPad 3", "Age": 999}
Note a ")" is missing from the back, and he returns the JSON object
But
POST Http://localhost:8080/RestEasy_02_Jsonp/json/product/post?callback=back
return: Back (Product created: [email protected]) OK, he returned a string.
Do not know what the problem, have to know the trouble to tell
Iv. Source code Download
Accessories: Resteasy_02_jsonp.zip
Resteasy 3.x Series three: Jsonp