package controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class HelloController implements Controller{
@Override
public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
ModelAndView mv= new ModelAndView("hello");
System.out.println("处理hello.action请求");
return mv;
}
}
7、在WEB-INF文件夹下新增"jsp"文件夹,并添加hello.jsp
<%@ 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>
<metahttp-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
欢迎来到Spring的世界!
</body>
</html>
8、跑起来吧兄弟们~然后访问,效果如下:
Spring MVC+Spring3+Hibernate4开发环境搭建
Spring MVC整合Freemarker基于注解方式