From 4a1370d1dd7984515887c396fda27a854f681205 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 15 May 2013 18:52:45 +0300 Subject: [PATCH] minor fixes --- .../spring/web/controller/FooController.java | 18 ++++++++++++++++-- spring-mvc/src/main/webapp/WEB-INF/web.xml | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) 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