Commits

Hector Miuler Malpica Gallegos  committed da99ed0

agregando cosas de spring

  • Participants
  • Parent commits d0d9d75

Comments (0)

Files changed (5)

     </repository>
   </repositories>
 
+  <packaging>war</packaging>
+
 </project>

File src/main/scala/com/miuler/prueba/web/HelloWorldController.scala

+package com.miuler.prueba.web
+
+import org.springframework.stereotype.Controller
+import org.springframework.web.bind.annotation.RequestMapping
+
+
+@Controller
+class HelloWorldController {
+
+	@RequestMapping(Array("/hello.html"))
+	def showHello = {
+        "helloPage"
+    }
+
+}
+

File src/main/webapp/WEB-INF/jsp/helloPage.jsp

+<%@page contentType="text/html;"%>
+<html>
+<body>
+  <h1>Hello from ${pageContext.request.serverName}</h1>
+</body>
+</html>

File src/main/webapp/WEB-INF/web-context.xml

+<?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:context="http://www.springframework.org/schema/context"
+    xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <context:component-scan
+        base-package="com.miuler.prueba.web" />
+
+    <bean id="viewResolver"
+          class="org.springframework.web.servlet.view.UrlBasedViewResolver">
+        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
+        <property name="prefix" value="/WEB-INF/jsp/"/>
+        <property name="suffix" value=".jsp"/>
+    </bean>
+
+</beans>

File src/main/webapp/WEB-INF/web.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="
+		http://java.sun.com/xml/ns/javaee
+		http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+	id="scala-spring-hibernate"
+	version="2.5">
+
+	<servlet>
+		<servlet-name>dispatcher</servlet-name>
+		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+		<init-param>
+			<param-name>contextConfigLocation</param-name>
+            <param-name>contextConfigLocation</param-name>
+			<param-value>/WEB-INF/web-context.xml</param-value>
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>dispatcher</servlet-name>
+		<url-pattern>*.html</url-pattern>
+	</servlet-mapping>
+
+</web-app>