Skip to content

HimalayFei/jsonp-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Include jsonp-filter in your pom.xml:

<dependencies>
  <dependency>
    <groupId>com.earldouglas</groupId>
    <artifactId>jsonp-filter</artifactId>
    <version>1.0.0</version>
  </dependency>
</dependencies>

Add a JsonPFilter to your web.xml:

<filter>
  <filter-name>jsonp-filter</filter-name>
  <filter-class>com.earldouglas.jsonpfilter.JsonPFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>jsonp-filter</filter-name>
  <url-pattern>/foo</url-pattern>
</filter-mapping>

Optionally configure the callback parameter name (defaults to callback):

<filter>
  <filter-name>jsonp-filter</filter-name>
  <filter-class>com.earldouglas.jsonpfilter.JsonPFilter</filter-class>
  <init-param>
    <param-name>callbackParam</param-name>
    <param-value>calleybackey</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>jsonp-filter</filter-name>
  <url-pattern>/foo</url-pattern>
</filter-mapping>

Now any requests to /foo will have their responses wrapped in callback(...). In the second case, responses will be wrapped in calleybackey(...).

About

A J2EE Servlet filter to wrap JSON responses in a JSONP callback

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published