当前位置:首页>正文

如何搭建springMVC开发环境 如何搭建spring mvc框架

2023-07-29 13:48:29 互联网 未知

如何搭建springMVC开发环境

1、去spring官网下载框架的包

下载依赖包:spring-framework-3.0.5.RELEASE-dependencies.zip
注意官网上3.0.3版本以后同版本依赖包不提供下载
2、导入所需jar包
引入dist目录下除了下面三个其余所有包
org.springframework.web.struts-3.1.0.RELEASE.jar
org.springframework.spring-library-3.1.0.RELEASE.libd
org.springframework.web.portlet-3.1.0.RELEASE.jar
引入依赖包下com.springsource.org.apache.commons.logging-1.1.1.jar及com.springsource.org.aopalliance-1.0.0.jar
3、spring框架配置
1、web.xml配置

contextConfigLocation

/WEB-INF/spring-servlet.xml


org.springframework.web.context.ContextLoaderListener



spring
org.springframework.web.servlet.DispatcherServlet
1



spring
/


4、应用上下文配置
spring-servlet.xml即配置用于开启基于注解的springMVC功能,照web.xml中设定,路径为WEB-INF下





如何搭建spring mvc框架

1、下载spring源包
我下的是spring-framework-3.1.0.RELEASE-with-docs.zip
下载依赖包:spring-framework-3.0.5.RELEASE-dependencies.zip
注意官网上3.0.3版本以后同版本依赖包不提供下载
2、导入所需jar包
引入dist目录下除了下面三个其余所有包
org.springframework.web.struts-3.1.0.RELEASE.jar
org.springframework.spring-library-3.1.0.RELEASE.libd
org.springframework.web.portlet-3.1.0.RELEASE.jar
引入依赖包下com.springsource.org.apache.commons.logging-1.1.1.jar及com.springsource.org.aopalliance-1.0.0.jar

使用maven创建springmvc项目



如图 是你的摄图展示方式不一样,
你可以选择 window-》show view-》package explorer 这样展示.
那个错误是你在线安装插件的时候安装失败吧?
可以考虑下载压缩文件的方式安装一下试试。

spring-webmvc4.0.0 xml怎么配置

spring web.xml 配置文件样例:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> characterEncodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 forceEncoding true characterEncodingFilter /* Spring MVC Dispatcher Servlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring/appServlet/servlet-context.xml 1 Spring MVC Dispatcher Servlet /

servlet-context.xml配置文件样例如下:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 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">