Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. @RestController
  2. public class TestServlet {
  3. @RequestMapping(value = "/test1")
  4. public String test1() {
  5. return "test1";
  6. }
  7.  
  8. @RequestMapping(value = "/test2")
  9. public String test2(@RequestBody TestClass req) {
  10. return "test2";
  11. }
  12.  
  13. public static class TestClass {
  14. private String value;
  15.  
  16. public String getValue() {
  17. return value;
  18. }
  19.  
  20. public void setValue(String value) {
  21. this.value = value;
  22. }
  23. }
  24. }
  25.  
  26. public String test2(@Valid TestClass req) {
  27. return "test2";
  28. }
  29.  
  30. Content-Type: application/json
  31. Accept: text/html (As your method returns only a String)
  32.  
  33. {
  34. "value":"the provided value"
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement