框架二:SpringMVC 以及小知识
首先说一下mvc
:mvc是一种设计模式,MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑、数据、界面显示分离的方法组织代码,将业务逻辑聚集到一个部件里面,在改进和个性化定制界面及用户交互的同时,不需要重新编写业务逻辑。 --------来自百度百科
进行Spring框架的搭建
1.使用maven,选择1.0----而不是默认
2.引入jar包
SpringMVC web
org.springframework
spring-webmvc
4.3.6.RELEASE
Servlet-api
javax.servlet
javax.servlet-api
3.1.0
provided
Jstl
javax.servlet
jstl
1.2
删除webapp 并生成web.xml
4.在web.xml 中 配置 Dispathcherservlet----servlet标签 不能缺少 还可以加上过滤器filter标签
Dispatcherservlet
servlet标签
springmvc org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:Springmvc.xml 找到配置文件
1
springmvc
/
filter过滤器
SetCharacterEncoding
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
SetCharacterEncoding
/*
4.建立Springmvc.xml文件
配置 扫描包,视图解析器,关于html5解析的 东西等
<context:component-scan
base-package=“com.qst”></context:component-scan>
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:resources location="/css/" mapping="/css/**"></mvc:resources>
<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
<mvc:resources location="/images/" mapping="/images/**"></mvc:resources>
5.建立Controller文件 使用注解,,方法返回String 返回 需要跳转的页面,,ajax则返回集合
6.整体架构