From 12b4cad504dd68fe25a55c16e22c6b21edfa8504 Mon Sep 17 00:00:00 2001 From: dineshmadhwal Date: Tue, 29 Nov 2016 02:29:37 +0800 Subject: [PATCH] Initial Commit --- spring-mvc-handlers/.classpath | 27 +++++++ spring-mvc-handlers/.project | 42 +++++++++++ spring-mvc-handlers/pom.xml | 70 +++++++++++++++++++ ...MethodHandlerAdapterExampleController.java | 17 +++++ ...appingHandlerAdapterExampleController.java | 17 +++++ ...rollerHandlerAdapterExampleController.java | 21 ++++++ .../src/main/resources/spring-servlet.xml | 31 ++++++++ .../src/main/webapp/WEB-INF/Greeting.jsp | 5 ++ .../src/main/webapp/WEB-INF/web.xml | 19 +++++ 9 files changed, 249 insertions(+) create mode 100644 spring-mvc-handlers/.classpath create mode 100644 spring-mvc-handlers/.project create mode 100644 spring-mvc-handlers/pom.xml create mode 100644 spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExampleController.java create mode 100644 spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExampleController.java create mode 100644 spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExampleController.java create mode 100644 spring-mvc-handlers/src/main/resources/spring-servlet.xml create mode 100644 spring-mvc-handlers/src/main/webapp/WEB-INF/Greeting.jsp create mode 100644 spring-mvc-handlers/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-handlers/.classpath b/spring-mvc-handlers/.classpath new file mode 100644 index 0000000000..c4978de982 --- /dev/null +++ b/spring-mvc-handlers/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc-handlers/.project b/spring-mvc-handlers/.project new file mode 100644 index 0000000000..25a99f0f7f --- /dev/null +++ b/spring-mvc-handlers/.project @@ -0,0 +1,42 @@ + + + SpringMVCHandlers + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-mvc-handlers/pom.xml b/spring-mvc-handlers/pom.xml new file mode 100644 index 0000000000..0074898767 --- /dev/null +++ b/spring-mvc-handlers/pom.xml @@ -0,0 +1,70 @@ + + 4.0.0 + com.baeldung + SpringMVCHandlers + war + 0.0.1-SNAPSHOT + SpringMVCHandlers Maven Webapp + http://maven.apache.org + + + 4.3.4.RELEASE + 3.5.1 + 2.6 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + + + commons-logging + commons-logging + 1.2 + + + org.springframework + spring-webmvc + ${springframework.version} + + + org.springframework + spring-context + ${springframework.version} + + + org.springframework + spring-core + ${springframework.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + src/main/webapp + springMVCHandlers + false + + + + + springMVCHandlers + + diff --git a/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExampleController.java b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExampleController.java new file mode 100644 index 0000000000..9837467e19 --- /dev/null +++ b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExampleController.java @@ -0,0 +1,17 @@ +package com.baeldung.spring.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class AnnotationMethodHandlerAdapterExampleController { + @RequestMapping("/annotedName") + public ModelAndView getEmployeeName() { + ModelAndView model = new ModelAndView("Greeting"); + + model.addObject("message", "Dinesh"); + + return model; + } +} diff --git a/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExampleController.java b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExampleController.java new file mode 100644 index 0000000000..012ba555dc --- /dev/null +++ b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExampleController.java @@ -0,0 +1,17 @@ +package com.baeldung.spring.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class RequestMappingHandlerAdapterExampleController { + @RequestMapping("/requestName") + public ModelAndView getEmployeeName() { + ModelAndView model = new ModelAndView("Greeting"); + + model.addObject("message", "Madhwal"); + + return model; + } +} diff --git a/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExampleController.java b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExampleController.java new file mode 100644 index 0000000000..59d932812c --- /dev/null +++ b/spring-mvc-handlers/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExampleController.java @@ -0,0 +1,21 @@ +package com.baeldung.spring.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.AbstractController; + +public class SimpleControllerHandlerAdapterExampleController extends +AbstractController { + +@Override +protected ModelAndView handleRequestInternal(HttpServletRequest arg0, + HttpServletResponse arg1) throws Exception { +ModelAndView model = new ModelAndView("Greeting"); + +model.addObject("message", "Dinesh Madhwal"); + +return model; +} +} \ No newline at end of file diff --git a/spring-mvc-handlers/src/main/resources/spring-servlet.xml b/spring-mvc-handlers/src/main/resources/spring-servlet.xml new file mode 100644 index 0000000000..eb42f89847 --- /dev/null +++ b/spring-mvc-handlers/src/main/resources/spring-servlet.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-handlers/src/main/webapp/WEB-INF/Greeting.jsp b/spring-mvc-handlers/src/main/webapp/WEB-INF/Greeting.jsp new file mode 100644 index 0000000000..820d2f380f --- /dev/null +++ b/spring-mvc-handlers/src/main/webapp/WEB-INF/Greeting.jsp @@ -0,0 +1,5 @@ + + +

Hello ${message}

+ + \ No newline at end of file diff --git a/spring-mvc-handlers/src/main/webapp/WEB-INF/web.xml b/spring-mvc-handlers/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d47deec14e --- /dev/null +++ b/spring-mvc-handlers/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + spring + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + classpath*:spring-servlet.xml + + 1 + + + spring + / + + \ No newline at end of file