简单的Spring MVC经典案例(2)

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经典案例

  

简单的Spring MVC经典案例

Spring MVC+Spring3+Hibernate4开发环境搭建

Spring MVC整合Freemarker基于注解方式

基于注解的Spring MVC简单介绍

Spring MVC 框架搭建及详解

Spring MVC使用Cron表达式的定时器

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/54464fa44051c0331aebb29d4444b03e.html