2. Crear el proyecto Spring MVC
2.1 Estructura de archivos
web.xml
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<web-app version=\"3.1\" xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd\">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
applicationContext.xml
<?xml version=\'1.0\' encoding=\'UTF-8\' ?>
<!-- was: <?xml version=\"1.0\" encoding=\"UTF-8\"?> -->
<beans xmlns=\"http://www.springframework.org/schema/beans\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:p=\"http://www.springframework.org/schema/p\"
xmlns:aop=\"http://www.springframework.org/schema/aop\"
xmlns:tx=\"http://www.springframework.org/schema/tx\"
xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd\">
<!--bean id=\"propertyConfigurer\"
class=\"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer\"
p:location=\"/WEB-INF/jdbc.properties\" />
<bean id=\"dataSource\"
class=\"org.springframework.jdbc.datasource.DriverManagerDataSource\"
p:driverClassName=\"${jdbc.driverClassName}\"
p:url=\"${jdbc.url}\"
p:username=\"${jdbc.username}\"
p:password=\"${jdbc.password}\" /-->
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
</beans>
dispatcher-servlet.xml
<?xml version=\'1.0\' encoding=\'UTF-8\' ?>
<!-- was: <?xml version=\"1.0\" encoding=\"UTF-8\"?> -->
<beans xmlns=\"http://www.springframework.org/schema/beans\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:p=\"http://www.springframework.org/schema/p\"
xmlns:aop=\"http://www.springframework.org/schema/aop\"
xmlns:tx=\"http://www.springframework.org/schema/tx\"
xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd\">
<bean class=\"org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping\"/>
<bean id=\"urlMapping\" class=\"org.springframework.web.servlet.handler.SimpleUrlHandlerMapping\">
<property name=\"mappings\">
<props>
<prop key=\"index.htm\">indexController</prop>
</props>
</property>
</bean>
<bean id=\"viewResolver\"
class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"
p:prefix=\"/WEB-INF/jsp/\"
p:suffix=\".jsp\" />
<bean name=\"indexController\"
class=\"org.springframework.web.servlet.mvc.ParameterizableViewController\"
p:viewName=\"index\" />
</beans>
index.jsp
<%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
<title>Welcome to Spring Web MVC project</title>
</head>
<body>
<p>Hello! This is the default welcome page for a Spring Web MVC project.</p>
<p><i>To display a different welcome page for this project, modify</i>
<tt>index.jsp</tt> <i>, or create your own welcome page then change
the redirection in</i> <tt>redirect.jsp</tt> <i>to point to the new
welcome page and also update the welcome-file setting in</i>
<tt>web.xml</tt>.</p>
</body>
</html>
redirect.jsp
<%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%>
<% response.sendRedirect(\"index.htm\"); %>
2.2 Ejecutar el proyecto autogenerado