Adds support for jsonp requests in Spring MVC controllers.
This project contains artifacts you can use for adding support for jsonp in your Spring MVC Controllers.
You can also use this in your Spring Roo projects to add jsonp support for controllers generated using @RooJson
and @RooWebJson
.
For more information on how this works, please read the following article.
Special thanks to the original author of the article.
-
Checkout the project from github or download the tar/zip file and extract it.
-
Run
mvn clean install
-
Add the following dependency to your project.
<dependency> <groupId>com.intera.util</groupId> <artifactId>spring-jsonp-support</artifactId> <version>0.0.2</version> </dependency>
-
Modify and add the following lines to each of the following files.
applicationContext.xml
<bean class="com.intera.util.web.servlet.filter.JsonpCallbackFilter" id="jsonpCallbackFilter" />
web.xml
<filter>
<filter-name>jsonpCallbackFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>jsonpCallbackFilter</filter-name>
<url-pattern>*.json</url-pattern>
</filter-mapping>
- When you are making the request, add .json at the end of the jsonp request and use a callback parameter.
Example : http://localhost:8080/mylistingsapp/listings.json?callback=myFunction
30 August 2014
- Project code migrated to Scala. Code currently available on Scala branch.
- The code will eventually take over the Java implementation.
8 September 2013
- Version bumped to version 0.0.2
- Improved logging
- Fixed issue #2 response truncated for callback function name length.
- Thanks to code contributions by wenin819 (https://github.com/wenin819)
This code contains no warranty. Use it at your own risk.
If you find any issues, please fork the project, fix it and do a pull request.
With love.