Skip to content

Commit 12b4cad

Browse files
committed
Initial Commit
1 parent 99b82f0 commit 12b4cad

9 files changed

Lines changed: 249 additions & 0 deletions

File tree

‎spring-mvc-handlers/.classpath‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="output" path="target/classes"/>
27+
</classpath>

‎spring-mvc-handlers/.project‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>SpringMVCHandlers</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.wst.validation.validationbuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>org.eclipse.m2e.core.maven2Builder</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
</buildSpec>
34+
<natures>
35+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
36+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
37+
<nature>org.eclipse.jdt.core.javanature</nature>
38+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
39+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
40+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
41+
</natures>
42+
</projectDescription>

‎spring-mvc-handlers/pom.xml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>SpringMVCHandlers</artifactId>
6+
<packaging>war</packaging>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<name>SpringMVCHandlers Maven Webapp</name>
9+
<url>http://maven.apache.org</url>
10+
11+
<properties>
12+
<springframework.version>4.3.4.RELEASE</springframework.version>
13+
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
14+
<maven-war-plugin.version>2.6</maven-war-plugin.version>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>javax.servlet</groupId>
20+
<artifactId>javax.servlet-api</artifactId>
21+
<version>3.1.0</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>commons-logging</groupId>
25+
<artifactId>commons-logging</artifactId>
26+
<version>1.2</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.springframework</groupId>
30+
<artifactId>spring-webmvc</artifactId>
31+
<version>${springframework.version}</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework</groupId>
35+
<artifactId>spring-context</artifactId>
36+
<version>${springframework.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework</groupId>
40+
<artifactId>spring-core</artifactId>
41+
<version>${springframework.version}</version>
42+
</dependency>
43+
</dependencies>
44+
<build>
45+
<pluginManagement>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-compiler-plugin</artifactId>
50+
<version>${maven-compiler-plugin.version}</version>
51+
<configuration>
52+
<source>1.7</source>
53+
<target>1.7</target>
54+
</configuration>
55+
</plugin>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-war-plugin</artifactId>
59+
<version>${maven-war-plugin.version}</version>
60+
<configuration>
61+
<warSourceDirectory>src/main/webapp</warSourceDirectory>
62+
<warName>springMVCHandlers</warName>
63+
<failOnMissingWebXml>false</failOnMissingWebXml>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
</pluginManagement>
68+
<finalName>springMVCHandlers</finalName>
69+
</build>
70+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.spring.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.servlet.ModelAndView;
6+
7+
@Controller
8+
public class AnnotationMethodHandlerAdapterExampleController {
9+
@RequestMapping("/annotedName")
10+
public ModelAndView getEmployeeName() {
11+
ModelAndView model = new ModelAndView("Greeting");
12+
13+
model.addObject("message", "Dinesh");
14+
15+
return model;
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.spring.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.servlet.ModelAndView;
6+
7+
@Controller
8+
public class RequestMappingHandlerAdapterExampleController {
9+
@RequestMapping("/requestName")
10+
public ModelAndView getEmployeeName() {
11+
ModelAndView model = new ModelAndView("Greeting");
12+
13+
model.addObject("message", "Madhwal");
14+
15+
return model;
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.spring.controller;
2+
3+
import javax.servlet.http.HttpServletRequest;
4+
import javax.servlet.http.HttpServletResponse;
5+
6+
import org.springframework.web.servlet.ModelAndView;
7+
import org.springframework.web.servlet.mvc.AbstractController;
8+
9+
public class SimpleControllerHandlerAdapterExampleController extends
10+
AbstractController {
11+
12+
@Override
13+
protected ModelAndView handleRequestInternal(HttpServletRequest arg0,
14+
HttpServletResponse arg1) throws Exception {
15+
ModelAndView model = new ModelAndView("Greeting");
16+
17+
model.addObject("message", "Dinesh Madhwal");
18+
19+
return model;
20+
}
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
4+
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
5+
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
6+
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
7+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
8+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
9+
10+
<!-- <bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /> -->
11+
12+
<!-- <bean name="/greeting.html" class="com.baeldung.spring.controller.SimpleControllerHandlerAdapterExampleController" /> -->
13+
14+
<context:component-scan base-package="com.baeldung.spring.controller"/>
15+
16+
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> -->
17+
18+
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> -->
19+
20+
<!-- <mvc:annotation-driven /> -->
21+
22+
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
23+
24+
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
25+
26+
<bean id="viewResolver"
27+
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
28+
<property name="prefix" value="/WEB-INF/" />
29+
<property name="suffix" value=".jsp" />
30+
</bean>
31+
</beans>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
<h1>Hello ${message}</h1>
4+
</body>
5+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
5+
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
6+
<servlet>
7+
<servlet-name>spring</servlet-name>
8+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
9+
<init-param>
10+
<param-name>contextConfigLocation</param-name>
11+
<param-value>classpath*:spring-servlet.xml</param-value>
12+
</init-param>
13+
<load-on-startup>1</load-on-startup>
14+
</servlet>
15+
<servlet-mapping>
16+
<servlet-name>spring</servlet-name>
17+
<url-pattern>/</url-pattern>
18+
</servlet-mapping>
19+
</web-app>

0 commit comments

Comments
 (0)