Skip to content

Commit

Permalink
BAEL-1221: How Spring MVC Really Works (eugenp#2892)
Browse files Browse the repository at this point in the history
  • Loading branch information
forketyfork authored and Eugen committed Oct 28, 2017
1 parent 26f38c1 commit d97456e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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;
Expand All @@ -28,4 +30,10 @@ public ModelAndView login(LoginData loginData) {
}
}

@ResponseBody
@PostMapping("/message")
public MyOutputResource sendMessage(@RequestBody MyInputResource inputResource) {
return new MyOutputResource("Received: " + inputResource.getRequestMessage());
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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!");
}

}

0 comments on commit d97456e

Please sign in to comment.