SpringMVC和spring集成zxwWord格式.docx

上传人:b****1 文档编号:15335237 上传时间:2022-10-29 格式:DOCX 页数:12 大小:172.18KB
下载 相关 举报
SpringMVC和spring集成zxwWord格式.docx_第1页
第1页 / 共12页
SpringMVC和spring集成zxwWord格式.docx_第2页
第2页 / 共12页
SpringMVC和spring集成zxwWord格式.docx_第3页
第3页 / 共12页
SpringMVC和spring集成zxwWord格式.docx_第4页
第4页 / 共12页
SpringMVC和spring集成zxwWord格式.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

SpringMVC和spring集成zxwWord格式.docx

《SpringMVC和spring集成zxwWord格式.docx》由会员分享,可在线阅读,更多相关《SpringMVC和spring集成zxwWord格式.docx(12页珍藏版)》请在冰豆网上搜索。

SpringMVC和spring集成zxwWord格式.docx

org.springframework.context.support-3.1.1.RELEASE.jar

org.springframework.core-3.0.5.RELEASE.jar:

spring核心包

org.springframework.web-3.0.5.RELEASE.jar:

web核心包,提供了web层接口

org.springframework.web.servlet-3.0.5.RELEASE.jar:

web层的一个具体实现包,DispatcherServlet也位于此包中。

org.springframework.asm-3.0.5.RELEASE.jar

mons.logging-1.1.1.jar

org.springframework.expression-3.0.5.RELEASE.jar

为了方便,建议在搭建环境中导入spring的所有jar包(所有jar包位于dist目录下),不需要的jar包可以在以后删除。

如果报错的话,可以导入下面jstl的两个核心jar包:

jstl.jarjstl标签的核心包。

standard.jar标准标签库包(此包也可以不导入)。

3、index.jsp首页内容:

<

body>

<

ahref="

spring/get.html"

>

第一步:

开始访问springMVC和spring集成<

/a>

br/>

/body>

4、success.jsp首页内容:

成功页面!

br>

5、web.xml内容:

?

xmlversion="

1.0"

encoding="

UTF-8"

web-appversion="

3.0"

xmlns="

xmlns:

xsi="

http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

display-name>

/display-name>

!

--加载顺序:

context-param>

listener>

filter>

servlet-->

context-param>

<

param-name>

contextConfigLocation<

/param-name>

param-value>

classpath:

spring/spring-core.xml<

/param-value>

/context-param>

listener>

<

listener-class>

org.springframework.web.context.ContextLoaderListener<

/listener-class>

/listener>

--第三步:

加载解析初始化Spring配置文件(利用总分配器DispatcherServlet处理请求到Spring配置文件)-->

servlet>

servlet-name>

User<

/servlet-name>

servlet-class>

org.springframework.web.servlet.DispatcherServlet<

/servlet-class>

--读取Spring配置文件,加载解析初始化(默认查找路径:

/WEB-INF/[servlet-name]-servlet.xml)-->

init-param>

<

--查找spring配置文件路径(不配置init-param的话,默认为/WEB-INF/下Login-servlet.xml)-->

spring/User-servlet.xml<

--classpath路径为:

\WebRoot\WEB-INF\classes-->

/init-param>

load-on-startup>

1<

/load-on-startup>

--tomcat启动时加载解析DispatcherServlet类(如果不设置启动,则第一次访问时启动,比较慢)-->

/servlet>

--第二步:

index页面请求映射-->

servlet-mapping>

url-pattern>

*.html<

/url-pattern>

/servlet-mapping>

--配置编码格式过滤器-->

filter>

filter-name>

EncodingFilter<

/filter-name>

filter-class>

org.springframework.web.filter.CharacterEncodingFilter<

/filter-class>

encoding<

UTF-8<

--初始化编码是UTF-8-->

forceEncoding<

true<

--强制转换response和request.setCharacterEncoding("

)编码格式-->

/filter>

--过滤器映射-->

filter-mapping>

/*<

--过滤所有请求-->

/filter-mapping>

welcome-file-list>

welcome-file>

index.jsp<

/welcome-file>

/welcome-file-list>

/web-app>

6、spring配置文件User-servlet.xml内容:

beansxmlns="

//www.springframework.org/schema/beans"

aop="

//www.springframework.org/schema/aop"

context="

//www.springframework.org/schema/context"

p="

//www.springframework.org/schema/p"

tx="

//www.springframework.org/schema/tx"

mvc="

//www.springframework.org/schema/mvc"

http:

//www.springframework.org/schema/beanshttp:

//www.springframework.org/schema/beans/spring-beans-3.0.xsd

http:

//www.springframework.org/schema/contexthttp:

//www.springframework.org/schema/context/spring-context-3.0.xsd

//www.springframework.org/schema/aophttp:

//www.springframework.org/schema/aop/spring-aop-3.0.xsd

//www.springframework.org/schema/txhttp:

//www.springframework.org/schema/tx/spring-tx-3.0.xsd"

--第四步:

启动注解组件扫描加载指定包下面的注解(需包含头部的:

xmlns、xmlns:

context、xmlns:

mvc、xsi:

schemaLocation)-->

context:

component-scanbase-package="

com.test"

/>

--第八步:

利用视图解析器继承扩展UrlBasedViewResolver的子类InternalResourceViewResolver解析返回的模型页面-->

beanclass="

org.springframework.web.servlet.view.InternalResourceViewResolver"

--<

propertyname="

viewClass"

value="

org.springframework.web.servlet.view.JstlView"

InternalResourceViewResolver解析器可以解析jstl所以不需要此viewClass-->

prefix"

/page/"

--此路径下文件安全性高,不可直接访问-->

suffix"

.jsp"

--查找文件的后缀-->

/bean>

/beans>

7、spring-core.xml内容:

DOCTYPEb

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 成人教育 > 成考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1