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- ...
随机推荐
- java 创建子类
当程序创建子类对象时,系统不仅会为该类中定义的实例变量分配内存,也会为他从父类继承得到的所有实例变量分配内存,即使子类中定义了与父类中同名的实例变量. 如: class Parent { privat ...
- WPF Demo4
<Window x:Class="Demo4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/ ...
- go的module用法
新版不需要项目放在GOPATH里面了,这个恶心的机制之前还被n多人捧臭脚.简单列一下用法 新建项目 cd 项目目录go mod init 项目名 写好代码 go build 或者 go mod tid ...
- asp.net 网站 发布时 去掉.cs文件
VS2013在WIN8下扁平的UI和我今天锈垢的大脑,让找这个设置找了好半天!!! OK,言归正传. 在要发布的网站上右键,选择"发布网站". 在发布窗口中,会让你选择 ...
- 关于office2016桌面新建不显示execl问题
在百度,google找了很多方法都没有文档可以解决此问题,office2016安装完在新建是由ececl的,应该是我用了清理注册表工具,对execl项进行清理,造成没有execl,所以贴出原版xls, ...
- bzoj3631 松鼠的新家
Description 松鼠的新家是一棵树,前几天刚刚装修了新家,新家有n个房间,并且有n-1根树枝连接,每个房间都可以相互到达,且俩个房间之间的路线都是唯一的.天哪,他居然真的住在“树”上.松鼠想邀 ...
- C# 在引用插件中 出现的问题| Csharp cite the plugin problem
背景:使用C#操纵鼠标进行重复性的工作 background: using Csharp to handle the keyboard or mouse to do the repetitive wo ...
- [转]修改DLL
部分内容来自:http://blog.csdn.net/csdncshuan/article/details/51477705 为没有源码的DLL文件添加强名称 如果项目中引用了其他没有源码的dll文 ...
- while循环的讲解
条件语句有两种方式: if() 条件语句 switch() 条件语句 循环语句: for() 循环语句 for in 遍历队象属性的循环 while 循环 案例:算出1到10的和 1.var i= ...
- 终端直接执行py文件,不需要python命令
然后给脚本文件运行权限,方法(1)chmod +x ./*.py方法(2)chmod 755 ./*.py (777也无所谓啦) 这个命令不去调整,会出现permission denied的错误终端直 ...