From 05cf9b75417e90e92e885de740bb1f65efa364e1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Thu, 9 Jan 2014 18:11:32 +0200 Subject: [PATCH] furthe example work --- .../config/{MvcConfig.java => WebConfig.java} | 6 +- .../BarMappingExamplesController.java} | 6 +- .../FooMappingExamplesController.java} | 8 +- .../web/controller/FooController.java | 6 +- .../src/main/webapp/WEB-INF/web.xml | 78 ++++++++++--------- 5 files changed, 54 insertions(+), 50 deletions(-) rename spring-rest/src/main/java/org/baeldung/config/{MvcConfig.java => WebConfig.java} (74%) rename spring-rest/src/main/java/org/baeldung/{controller/BarController.java => web/controller/BarMappingExamplesController.java} (91%) rename spring-rest/src/main/java/org/baeldung/{controller/FooController.java => web/controller/FooMappingExamplesController.java} (94%) diff --git a/spring-rest/src/main/java/org/baeldung/config/MvcConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java similarity index 74% rename from spring-rest/src/main/java/org/baeldung/config/MvcConfig.java rename to spring-rest/src/main/java/org/baeldung/config/WebConfig.java index 18924ad855..c26e09ca54 100644 --- a/spring-rest/src/main/java/org/baeldung/config/MvcConfig.java +++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java @@ -6,10 +6,10 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; @EnableWebMvc @Configuration -@ComponentScan({ "org.baeldung.controller" }) -public class MvcConfig { +@ComponentScan({ "org.baeldung.web" }) +public class WebConfig { - public MvcConfig() { + public WebConfig() { super(); } diff --git a/spring-rest/src/main/java/org/baeldung/controller/BarController.java b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java similarity index 91% rename from spring-rest/src/main/java/org/baeldung/controller/BarController.java rename to spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java index d85c410862..46e8bcf975 100644 --- a/spring-rest/src/main/java/org/baeldung/controller/BarController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/BarMappingExamplesController.java @@ -1,4 +1,4 @@ -package org.baeldung.controller; +package org.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -7,9 +7,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @Controller -public class BarController { +public class BarMappingExamplesController { - public BarController() { + public BarMappingExamplesController() { super(); } diff --git a/spring-rest/src/main/java/org/baeldung/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java similarity index 94% rename from spring-rest/src/main/java/org/baeldung/controller/FooController.java rename to spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java index 292f46729a..e031ac13de 100644 --- a/spring-rest/src/main/java/org/baeldung/controller/FooController.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooMappingExamplesController.java @@ -1,4 +1,4 @@ -package org.baeldung.controller; +package org.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -7,15 +7,15 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller -public class FooController { +public class FooMappingExamplesController { - public FooController() { + public FooMappingExamplesController() { super(); } // API - // by paths + // mapping examples @RequestMapping(value = "/foos") @ResponseBody diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java index 642878b918..cd0153540f 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/FooController.java @@ -31,14 +31,16 @@ public class FooController { // API - // read + // read - single @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Foo findOne(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + public Foo findById(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { return new Foo(randomAlphabetic(6)); } + // read - multiple + @RequestMapping(method = RequestMethod.GET) @ResponseBody public List findAll() { diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml index fe62026bc7..a33a3fd2c1 100644 --- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,52 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring MVC Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + + \ No newline at end of file