Spring Mvc ==> Struts2
spring 无法替代
myBatis 工作量大 要自己操作sql语句 ==> hibernate
Spring Mvc 取代Stuts2 开发快 运行效率高
mode 指整个界面层
1.在lib文件夹导入所要jar
2、配置web.xml
3.配置springmvc-servlet.xml 进行详细配置
.配置springmvc-servlet.xml 进行详细配置
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
">
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/views/" p:suffix=".jsp"
p:viewClass="org.springframework.web.servlet.view.JstlView">
springmvc-servlet.xml配置放到src下面
4.编写controller
package com.study.it.ui.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/abc")//struts.xml
public class HelloController {
@RequestMapping("/hh")
public String hi(){
System.out.println("hello,world");
return "login_page";
}
}