@Target(value=PARAMETER) @Retention(value=RUNTIME) @Documented @InjectedParameter(value=JsonBody.Handler.class) public @interface JsonBody
On a web-bound doXyz
method, use this method on a parameter to get the content of the request
data-bound to a bean through JSONObject.fromObject(Object)
and inject it as a parameter.
For example,
@JsonResponse public Point doDouble(@JsonBody Point p) { Point pt = new Point(); pt.x = p.x*2; pt.y = p.y*2; return pt; } public static class Point { public int x, y; }Request:
POST ..../double Content-Type: application/json {"x":10,"y":5}Response:
200 OK Content-Type: application/json;charset=UTF-8 {"x":20,"y":10}
JsonResponse
Copyright © 2004–2022. All rights reserved.