net.sue445.kulib.controller
Class JsonController
java.lang.Object
org.slim3.controller.Controller
org.slim3.controller.SimpleController
net.sue445.kulib.controller.JsonController
public abstract class JsonController
- extends SimpleController
A Controller
which is print response as JSON or JSONP
example
public Navigation run() throws Exception {
String json = ... ;
String jsonp = toJsonp(json);
return responseJson(jsonp);
}
- Since:
- 0.0.4
- Author:
- sue445
Methods inherited from class org.slim3.controller.Controller |
applicationScope, applicationScope, asBoolean, asDate, asDouble, asDouble, asFloat, asFloat, asInteger, asInteger, asKey, asLong, asLong, asMap, asShort, asShort, asString, download, download, encodeFileName, forward, getForwardServletPath, handleError, isDelete, isDevelopment, isGet, isPost, isPut, param, paramValues, redirect, removeApplicationScope, removeRequestScope, removeSessionScope, requestScope, requestScope, run, runBare, sessionScope, sessionScope, show, show, tearDown |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_CHARSET
protected static final Charset DEFAULT_CHARSET
CONTENT_TYPE_PREFIX
protected static final String CONTENT_TYPE_PREFIX
- See Also:
- Constant Field Values
callback
protected String callback
- JSONP callback
JsonController
public JsonController()
setUp
protected Navigation setUp()
- Overrides:
setUp
in class Controller
toJsonp
protected String toJsonp(String jsonContent)
- if exists callback, add this to json content
- Parameters:
jsonContent
-
- Returns:
responseJson
protected Navigation responseJson(String jsonContent)
throws IOException
- print json response(UTF-8) and finish contoller
- Parameters:
jsonContent
-
- Returns:
-
- Throws:
IOException
responseJson
protected Navigation responseJson(String jsonContent,
Charset charset)
throws IOException
- print json response and finish contoller
- Parameters:
jsonContent
- charset
-
- Returns:
-
- Throws:
IOException
response
protected Navigation response(String content,
Charset charset,
String contentType)
throws IOException
- print string to response
- Parameters:
content
- charset
- contentType
-
- Returns:
-
- Throws:
IOException
Copyright © 2013. All Rights Reserved.