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- ...
随机推荐
- ES(3): ES Cluster Extended Azure Storage
Azure VM的磁盘空间远远不能满足ES集群存储需求(还需除掉VM的临时盘),同时也未找着ES配置 block blob storage 存储的组件,因此下文介绍通过挂载附加盘的方式增加ES集群存储 ...
- json格式字符串处理
public class InternalClass { public int MID; public string Name; ...
- java web程序 上机考试登陆界面设计实现
今天是java web上机.做一个登陆注册的界面.要求:jsp.mysql数据库,js做一个美观的界面.功能.可以添加 更多啊.我做的界面被老师狠狠的扣了分.问题在于.当用户没有输入任何信息(没有输入 ...
- 学习笔记之Unit testing/Integration testing/dotnet test and xUnit
source code https://github.com/haotang923/dotnet/tree/master/src Unit testing C# code in .NET Core u ...
- nginx的日志分析
1.到NGINX把日志DOWN下来2.用命令cat xxxx.log | egrep '10/Jul/2015:01:[4-5]|2015-07-10 02:0[0-57]'>xxxx2.log ...
- python protobuf序列化repeated运用
下面是proto描述文件的定义 message Person { required string name = 1; required int32 id = 2; optional string em ...
- oracle 所有 hint(转)
oracle 10g 有64个hints , 11g 增加到71 个, 下表中红色的代表已经过时的, 粗体的是11g 新增. Optimization Goals and Approaches (2) ...
- Flex工程师面试
这几天有一家公司需要招聘Flex开发的工程师,要求开发电力行业的WebGIS的电力方面的程序,当时也是被推荐过去的,随后的几天,自己也准备的一下,因为之前接触Flex的主要是开发一些医疗的项目,利用F ...
- CSS3基础
内容: 1.圆角 border-radius 2.阴影 text-shadow.box-shadow 3.渐变 linear.radial 4.rgba rgb+alpha opacity 5.tra ...
- Survival Coxph log-rank
Difference between survdiff log-rank and coxph log-rank Ask Question 6 1 I'm using the survival pack ...