diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java index c39da4e3e5..04adb9211e 100644 --- a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java @@ -4,6 +4,8 @@ import com.forketyfork.guest.springmvc.model.LoginData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import java.util.Collections; @@ -28,4 +30,10 @@ public class InternalsController { } } + @ResponseBody + @PostMapping("/message") + public MyOutputResource sendMessage(@RequestBody MyInputResource inputResource) { + return new MyOutputResource("Received: " + inputResource.getRequestMessage()); + } + } diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyInputResource.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyInputResource.java new file mode 100644 index 0000000000..4c30cfb842 --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyInputResource.java @@ -0,0 +1,14 @@ +package com.forketyfork.guest.springmvc.web; + +public class MyInputResource { + + private String requestMessage; + + public String getRequestMessage() { + return requestMessage; + } + + public void setRequestMessage(String requestMessage) { + this.requestMessage = requestMessage; + } +} diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyOutputResource.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyOutputResource.java new file mode 100644 index 0000000000..bcb76056a4 --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/MyOutputResource.java @@ -0,0 +1,15 @@ +package com.forketyfork.guest.springmvc.web; + +public class MyOutputResource { + + private String responseMessage; + + public MyOutputResource(String responseMessage) { + this.responseMessage = responseMessage; + } + + public String getResponseMessage() { + return responseMessage; + } + +} diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/RestfulWebServiceController.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/RestfulWebServiceController.java new file mode 100644 index 0000000000..820c80db7a --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/RestfulWebServiceController.java @@ -0,0 +1,14 @@ +package com.forketyfork.guest.springmvc.web; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class RestfulWebServiceController { + + @GetMapping("/message") + public MyOutputResource getMessage() { + return new MyOutputResource("Hello!"); + } + +}