demo page added.

This commit is contained in:
shuyouxiangming 2013-07-05 17:52:01 +08:00
parent a379e745e7
commit 833c72f3df
4 changed files with 35 additions and 1 deletions

View File

@ -27,6 +27,13 @@
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>bench4q-web</finalName>

View File

@ -1,16 +1,25 @@
package org.bench4q.web.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/")
public class HomeController {
@RequestMapping(method = { RequestMethod.GET })
@RequestMapping(value = "/", method = { RequestMethod.GET })
@ResponseBody
public String index() {
return "It works!";
}
@RequestMapping(value = "/demo", method = { RequestMethod.GET })
public ModelAndView d(HttpServletRequest request) {
request.setAttribute("Test", "Abc");
return new ModelAndView("demo");
}
}

View File

@ -7,4 +7,9 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.bench4q" />
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>

View File

@ -0,0 +1,13 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
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>Demo</title>
</head>
<body>
It works!
<%=request.getAttribute("Test")%>
</body>
</html>