Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- request.read(Person.class).as(Json.class);
- at("/test").serve(TestPage.class);
- public class TestPage {
- private String param;
- @Get
- public Reply<?> get() {
- // request get param "param" is already mapped in param
- }
- @Post
- public Reply<?> post() {
- // request post param "param" is already mapped in param
- }
- public void setParam(String param) {
- this.param = param;
- }
- public String getParam() {
- return this.param;
- }
- }
- public class TestPage {
- @Inject Json json;
- @Post
- public void post(Request request) {
- String data = request.param("data");
- Person p = json.in(new ByteArrayInputStream(data.getBytes()), Person.class);
- ...
- }
- }
Add Comment
Please, Sign In to add comment