springmvc框架的搭建
1引入jar包
jar包下载地址http://maven.springframework.org/release/org/
以下是我引入的jar包
aopalliance-1.0.jar
aspectjrt.jar
aspectjweaver.jar
commons-beanutils-1.8.0.jar
commons-codec-1.6.jar
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-fileupload-1.2.1.jar
commons-io-2.0.1.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
commons-logging-1.1.3.jar
commons-net-2.2.jar
commons-pool-1.2.jar
freemarker-2.3.19.jar
hamcrest-all-1.3.jar
httpclient-4.4-beta1.jar
jackson-core-asl-1.9.12.jar
jackson-mapper-asl-1.9.12.jar
json-20090211.jar
json-lib-2.4-jdk15.jar
jsoup-1.7.2.jar
junit-4.11.jar
log4j-1.2.16.jar
mysql-connector-java-5.0.8-bin.jar
spring-aop-3.2.9.RELEASE.jar
spring-aspects-3.2.9.RELEASE.jar
spring-beans-3.2.9.RELEASE.jar
spring-context-3.2.9.RELEASE.jar
spring-context-support-3.2.9.RELEASE.jar
spring-core-3.2.9.RELEASE.jar
spring-expression-3.2.9.RELEASE.jar
spring-framework-bom-3.2.9.RELEASE.jar
spring-instrument-3.2.9.RELEASE.jar
spring-jdbc-3.2.9.RELEASE.jar
spring-orm-3.2.9.RELEASE.jar
spring-oxm-3.2.9.RELEASE.jar
spring-test-3.2.9.RELEASE.jar
spring-tx-3.2.9.RELEASE.jar
spring-web-3.2.9.RELEASE.jar
spring-webmvc-3.2.9.RELEASE.jar
struts2-json-plugin-2.3.15.1.jar
xmlschema-core-2.0.jar
xstream-1.3.1.jar
2导入log4j文件(自己去网上找,不用也没关系,主要是为了进行检测项目的运行状态,进行报错处理)
3在src 目录下写一个applicationContext.xml文件
头部如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
">
<description>Spring-初始 </description>
<!-- //开启mvc注解模式--->
<mvc:annotation-driven />
<!---//扫包() (web层的注解不在这个文件扫描) -->
<context:component-scan:base-package="包名">
<context:component-scan:base-package="包名">
<!---创建对象实例 相当于Object obj = new Object() , obj.prop1 = ""....;整个容器中只存一个实例,从而大大降低了内存的消耗。这里以配置一个数据源为例--->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.jdbc.mysql.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/test"></property>
<property name ="username" value="root"></property>
<property name="password" value="password"></property>
</bean>
</beans>
4.在WEB-INF目录下新建一个xml文件 格式为 项目名-servlet.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!--
扫描web包,应用Spring的注解
*代表是类
**类和包
Annotation-specified bean name 'userController'
for bean class [com.tz.web.user.UserController]
conflicts with existing, non-compatible bean definition of same name and class
[com.tz.web.UserController
-->
<!--扫描web层-->
<context:component-scan base-package="com.zd.web.**"/>
<!-- 配置视图解析器,将ModelAndView及字符串解析为具体的页面 -->
<bean class="org.springframework.web.servlet.view.InternalResoureViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"
/>
<!-- springmvc 资源文件管理,异常处理,拦截器,数据类型转换,视频,ajax,文件上传,验证码,路径的说明,参数传递和解说. -->
</beans>
5配置web.xml
?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SpringFirst</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 监听上下文每一个实例的变化 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!--servlet-mapping -->
<servlet>
<servlet-name>SpringFirst</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringFirst</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
springmvc框架的搭建的更多相关文章
- SpringMVC 框架的搭建及基本功能的实现
首先新建一个WEB项目 导入jar包 我们基于Spring mvc框架进行开发,需要依赖一下的spring jar包: spring-aop-4.0.4.RELEASE.jar spring-bean ...
- Spring学习之SpringMVC框架快速搭建实现用户登录功能
引用自:http://blog.csdn.net/qqhjqs/article/details/41683099?utm_source=tuicool&utm_medium=referral ...
- springmvc框架简单搭建
一.利用xml 配置 1.web.xml <web-app version="2.4" xmlns="http://java.sun.com/xml/n ...
- Idea搭建SpringMVC框架(初次接触)
公司转Java开发,做的第一个项目是SpringMVC框架,因为底层是同事封装,等完成整个项目,对SpringMVC框架的搭建还不是很了解,所以抽时间不忙的时候自己搭建了一个SpringMVC框架. ...
- 基于maven从头搭建springMVC框架
0.准备工作 首先将eclipse和需要的插件准备好,例如maven插件,spring IDE插件. 1.建立maven下的webapp项目 1.新建一个maven项目,类型为webapp,如下图 2 ...
- springMVC学习篇 - 搭建环境及关键点
springMVC是spring家族中一个重要的组件,和struts一样作为一套前台框架被广泛的应用于各种项目. 之前在很多项目组都用到springMVC,只感觉很强大,但是对这套框架的知识了解比较少 ...
- Spring+SpringMvc+Mybatis框架集成搭建教程
一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以在自己搭建SSM框架集成的时候,出现了这样或者那样的问题,很是苦恼 ...
- SpringMVC框架搭建 基于注解
本文将以一个很简单的案例实现 Springmvc框架的基于注解搭建,一下全为个人总结 ,如有错请大家指教!!!!!!!!! 第一步:创建一个动态web工程(在创建时 记得选上自动生成 web.xml ...
- 教你搭建SpringMVC框架( 更新中、附源码)
一.项目目录结构 二.SpringMVC需要使用的jar包 commons-logging-1.2.jar junit-4.10.jar log4j-api-2.0.2.jar log4j-core- ...
随机推荐
- oracle常用数据类型说明
类型 含义 存储描述 备注 CHAR 固定长度字符串 最大长度2000bytes VARCHAR2 可变长度的字符串, 最大长度4000bytes 可做索引的最大长度749 NCHAR 根据字符集而定 ...
- oracle 导入excel
方法二.利用PLSQL Developer使用PLSQL Developer工具,这个可是大名鼎鼎的Oracle DBA最常使用的工具.在单个文件不大的情况下(少于100000行),并且目的表结构已经 ...
- valgrind的使用--检测内存
valgrind主要检测内存的使用情况,检测有否内存泄露等. 比如:test_va2.cpp #include<iostream> using namespace std; int mai ...
- Extjs下拉多选框
//------录入时间,下拉列表框------ var inputTimeRow = new Ext.data.Record.create([ { name : 'value' },{ name : ...
- php 非常简单的导入sql文件
在网上找了很多,都是写了一个类 做了各种处理.还真是累哦 当然之前也做了各种尝试 source 客户端命令 mysql_query()是不支持的 load_file 在where 之后执行可以,但是 ...
- eclipse 新项目导入到tfs 步骤
为了下次导入项目 不动脑子,写下此步骤.... 1.右键要导入的项目>> share project(如果有这项就点它,然后 进入 分享至你的tfs服务器即可) 1.右键要导入的项目> ...
- springMVC学习(10)-上传图片
需求:在修改商品页面,添加上传商品图片功能. SpringMVC中对多部件类型解析: 1)springmvc中配置: <!-- 文件上传 --> <bean id="mul ...
- [转]利用C#自带组件强壮程序日志
利用C#自带组件强壮程序日志 在项目正式上线后,如果出现错误,异常,崩溃等情况 我们往往第一想到的事就是查看日志 所以日志对于一个系统的维护是非常重要的 声明 正文中的代码只是一个栗子,一个非常简 ...
- Python 常用PEP8规范
目录 目录 代码布局 缩进 最大行宽 空行 模块导入 字符串 表达式和语句中的空格 注释 命名规则 编程建议 代码布局 缩进 每级缩进用4个空格. 括号中使用垂直隐式缩进或使用悬挂缩进. EXAMPL ...
- 运行inetmgr提示“找不到文件”无法打开IIS管理器的解决办法
运行inetmgr提示“找不到文件”无法打开IIS管理器的解决办法 不知道什么时候开始运行inetmgr就提示找不到文件了,本以为是IIS坏了,这两天发现IIS服务还是可以运行的,只是运行inetmg ...