diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java index a2628cbbbf..3698cc24d5 100644 --- a/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/controller/FooController.java @@ -2,6 +2,8 @@ package org.baeldung.spring.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; @Controller public class FooController { @@ -13,9 +15,21 @@ public class FooController { // API @RequestMapping(value = "/foos") + @ResponseBody public String getFoos() { - System.out.println("simplePattern method was called"); - return "someResult"; + return "Get some Foos"; + } + + @RequestMapping(value = "/foos", method = RequestMethod.POST) + @ResponseBody + public String getFoosPost() { + return "Post some Foos"; + } + + @RequestMapping(value = "/foos", method = RequestMethod.POST, headers = "key=val") + @ResponseBody + public String getFoosWithHeader() { + return "Get some Foos with Header"; } } diff --git a/spring-mvc/src/main/webapp/WEB-INF/web.xml b/spring-mvc/src/main/webapp/WEB-INF/web.xml index ba2bb591ed..5c163a20ad 100644 --- a/spring-mvc/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc/src/main/webapp/WEB-INF/web.xml @@ -36,7 +36,7 @@ - index.html + \ No newline at end of file