简单的springmvc框架
来源:互联网 发布:t95e6最新版本数据 编辑:程序博客网 时间:2024/06/09 23:42
1、新建一个WEB项目
2 、插入spring配置文件 applicationContext.xml,插入文件中有一个选项是否导入jar ,如果没有选则自己导入,我有jar自己导入
3、导入spring所需求jar
4、编辑applicationContext.xml、spring-mvc.xml文件
applicationContext.xml 建立与数据的链接
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${c3p0.driverClass}"></property> <property name="jdbcUrl" value="${c3p0.url}"></property> <property name="user" value="${c3p0.user}"></property> <property name="password" value="${c3p0.password}"></property> <property name="acquireIncrement" value="${c3p0.acquireIncrement}"></property> <property name="initialPoolSize" value="${c3p0.initialPoolSize}"></property> <property name="maxIdleTime" value="${c3p0.maxIdleTime}"></property> <property name="maxPoolSize" value="${c3p0.maxPoolSize}"></property> <property name="minPoolSize" value="${c3p0.minPoolSize}"></property> <property name="acquireRetryDelay" value="1000"></property> <property name="acquireRetryAttempts" value="60"></property> <property name="breakAfterAcquireFailure" value="false"></property> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="transationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven> <bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>classpath*:c3p0.properties</value> </list> </property> </bean> <bean id="defaultTransactionDefinition" class="org.springframework.transaction.support.DefaultTransactionDefinition"></bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer" > <property name="properties" ref="configProperties"></property> </bean> </beans>
spring-mvc.xml
<beans xmlns="http://www.springframework.org/schema/beans"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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"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.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射 --> <context:component-scan base-package="org.springframework.core.serializer.annotation"></context:component-scan> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="prefixJson" value="false"></property> <property name="supportedMediaTypes"> <list> <value>application/json</value> <value>text/json</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean --> <context:component-scan base-package="com.action" /> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/pages/" p:suffix=".jsp"></bean> <!-- 上传 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="utf-8"></property> <property name="maxUploadSize" value="10485760000"></property> <property name="maxInMemorySize" value="40960"></property> </bean> </beans>
文档结构路径如下:
阅读全文
0 0
- 简单的springmvc框架
- 建立简单的SpringMVC框架
- 手写简单的springmvc框架
- SpringMvc一个简单的框架入门程序
- JavaEE_Mybatis_SpringMVC_SpringMVC_lesson1_简单的SpringMVC框架搭建指南
- 搭建一个简单的springMVC框架
- SpringMVC和mybatis框架的简单整合
- 简单的 spring + springMVC + mybaties 框架搭建
- springmvc框架环境的简单搭建
- 简单的maven形式springmvc框架搭建
- 一个简单的SpringMVC框架web程序
- 搭建最简单的SpringMVC框架
- SpringMVC 框架中,@RequestParam 的简单用法
- springMVC框架简单搭建
- 一个简单的HelloWord SpringMVC框架的搭载
- springmvc框架的搭建以及实现简单的文件上传
- 一个简单的springmvc框架写的 helloworld例子
- 快速搭建简单的springMvc框架的动态web工程
- Spring学习笔记5
- 【转载】PHP中使用单引号与双引号的区别
- jQuery ajax的标准写法
- 创建数据库。将eclipse链接数据库
- Linux的网络配置(虚拟机安装redhat版本系统)
- 简单的springmvc框架
- spring boot (二) servlet listener filter interceptor
- android和js交互你真的了解吗
- Select下拉框onchange事件获取option的value值
- C#操作符??和?:
- 手机中的AR是怎么实现的
- IMS基本概念之 控制承载通道媒体流的机制(SBLP)
- NAND驱动分析--(三)
- 运维之高级服务篇------ 3.部署LNMP 、 Nginx+FastCGI 、 Nginx高级技术