Guest User

Untitled

a guest
Jan 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. request.read(Person.class).as(Json.class);
  2.  
  3. at("/test").serve(TestPage.class);
  4.  
  5. public class TestPage {
  6.  
  7. private String param;
  8.  
  9. @Get
  10. public Reply<?> get() {
  11. // request get param "param" is already mapped in param
  12. }
  13.  
  14. @Post
  15. public Reply<?> post() {
  16. // request post param "param" is already mapped in param
  17. }
  18.  
  19.  
  20. public void setParam(String param) {
  21. this.param = param;
  22. }
  23.  
  24. public String getParam() {
  25. return this.param;
  26. }
  27.  
  28. }
  29.  
  30. public class TestPage {
  31. @Inject Json json;
  32.  
  33. @Post
  34. public void post(Request request) {
  35. String data = request.param("data");
  36. Person p = json.in(new ByteArrayInputStream(data.getBytes()), Person.class);
  37.  
  38. ...
  39. }
  40. }
Add Comment
Please, Sign In to add comment