JavaScript is disabled on your browser.
play.libs

Class Jsonp

  • All Implemented Interfaces:
    Content


    public class Jsonp
    extends java.lang.Object
    implements Content 
    The JSONP Content renders a JavaScript call of a JSON object.
    Example of use, provided the following route definition:
     GET /my-service Application.myService(callback: String)
     
    The following action definition:
     public static Result myService(String callback) {
     JsonNode json = ...
     return ok(jsonp(callback, json));
     }
     
    And the following request:
     GET /my-service?callback=foo
     
    The response will have content type "text/javascript" and will look like the following:
     foo({...});
     
    • Constructor Summary

      Constructors
      Constructor and Description
      Jsonp (java.lang.String padding, org.codehaus.jackson.JsonNode json)
    • Method Summary

      Methods
      Modifier and Type Method and Description
      java.lang.String body ()
      java.lang.String contentType ()
      static Jsonp jsonp (java.lang.String padding, org.codehaus.jackson.JsonNode json)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Jsonp

        public Jsonp(java.lang.String padding,
         org.codehaus.jackson.JsonNode json)
    • Method Detail

      • body

        public java.lang.String body()
      • contentType

        public java.lang.String contentType()
      • jsonp

        public static Jsonp jsonp(java.lang.String padding,
         org.codehaus.jackson.JsonNode json)
        Parameters:
        padding - Name of the callback
        json - Json content
        Returns:
        A JSONP Content using padding and json.

AltStyle によって変換されたページ (->オリジナル) /