标签:adsi ring mysq one style 注册 handler work 处理器
项目说明
1、项目文件结构
2、项目主要接口及其实现
(1)Index:
首页页面:展示商品功能,可登录或查看商品详细信息
(2)登录:/ApiLogin
3、dao层
数据持久化层,把商品和用户信息寸进mysql数据库
(1)ContentDao
(2)PersonDao
(3)ProductDao
(4)TransactionDao
4、spring配置文件和mybatis配置文件
spring-mvc.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:context="http://www.springframework.org/schema/context" 5 xmlns:mvc="http://www.springframework.org/schema/mvc" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans 7 http://www.springframework.org/schema/beans/spring-beans.xsd 8 http://www.springframework.org/schema/context 9 http://www.springframework.org/schema/context/spring-context.xsd 10 http://www.springframework.org/schema/mvc 11 http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 12 13 <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> 14 <context:component-scan base-package="com.web.controller"></context:component-scan> 15 <!-- 扩充了注解驱动,可以将请求参数绑定到控制器参数 --> 16 <mvc:annotation-driven/> 17 <mvc:default-servlet-handler/> 18 19 <!-- 配置事务管理器 20 <bean id="transactionManager" 21 class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 22 <!- 注入数据库连接池 -> 23 <property name="dataSource" ref="dataSource"/> 24 </bean> 25 --> 26 <!-- freemarker配置 --> 27 <bean id="freemarkerConfig" 28 class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> 29 <property name="templateLoaderPath" value="/WEB-INF/freemarker" /> 30 <property name="templateLoaderPaths" value="/template"/> 31 <property name="freemarkerSettings"> 32 <props> 33 <prop key="template_update_delay">0</prop><!--刷新模板的周期,单位为秒--> 34 <prop key="defaultEncoding">UTF-8</prop><!--模板的编码格式 --> 35 </props> 36 </property> 37 </bean> 38 <!-- freemarker视图解析器 --> 39 <bean 40 class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> 41 <property name="viewResolvers"> 42 <list> 43 <bean id="viewResolver" 44 class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> 45 <property name="cache" value="true" /> 46 <property name="prefix" value="" /> 47 <property name="suffix" value=".ftl" /> 48 <property name="contentType" value="text/html; charset=UTF-8" /> 49 </bean> 50 </list> 51 </property> 52 <property name="defaultViews"> 53 <list> 54 <bean 55 class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> 56 </list> 57 </property> 58 </bean> 59 <!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 --> 60 <bean id="multipartResolver" 61 class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> 62 <property name="defaultEncoding" value="UTF-8" /> 63 <!-- 指定所上传文件的总大小,单位字节。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 --> 64 <property name="maxUploadSize" value="10240000" /> 65 </bean> 66 67 <!--注册拦截器--> 68 69 </beans>
spring-mybatis.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 配置文件需要引入的类 --> 3 <beans xmlns="http://www.springframework.org/schema/beans" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xmlns:context="http://www.springframework.org/schema/context" 6 xmlns:mybatis="http://mybatis.org/schema/mybatis-spring" 7 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 8 9 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 10 11 12 13 14 http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd"> 15 <!-- scanner --> 16 <context:component-scan base-package="com.web.service"></context:component-scan> 17 <context:component-scan base-package="com.web.service.impl"></context:component-scan> 18 19 20 <!-- Spring and mybatis--> 21 <mybatis:scan base-package="com.web.dao"/> 22 23 24 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 25 <property name="dataSource" ref="dataSource"/> 26 </bean> 27 28 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 29 destroy-method="close"> 30 <property name="driverClassName" value="${jdbc.driverClassName}"></property> 31 <property name="url" value="${jdbc.url}"></property> 32 <property name="username" value="${jdbc.username}"></property> 33 <property name="password" value="${jdbc.password}"></property> 34 <!-- 初始化连接大小 --> 35 <property name="initialSize" value="${initialSize}"></property> 36 <!-- 连接池最大数量 --> 37 <property name="maxActive" value="${maxActive}"></property> 38 <!-- 连接池最大空闲 --> 39 <property name="maxIdle" value="${maxIdle}"></property> 40 <!-- 连接池最小空闲 --> 41 <property name="minIdle" value="${minIdle}"></property> 42 <!-- 获取连接最大等待时间 --> 43 <property name="maxWait" value="${maxWait}"></property> 44 </bean> 45 46 <context:property-placeholder location="classpath:db.properties"/> 47 48 <!-- 配置基于注解的声明式事务 49 <bean id="transactionManager" 50 class="org.springframework.orm.jpa.JpaTransactionManager"> 51 <property name="dataSource" ref="dataSource" /> 52 </bean> 53 54 <tx:annotation-driven transaction-manager="transactionManager"/> 55 --> 56 </beans>
db.properties
1 jdbc.driverClassName= com.mysql.jdbc.Driver 2 jdbc.url= jdbc:mysql://localhost:3306/shen_db?characterEncoding=utf8&useSSL=true 3 jdbc.username=root 4 jdbc.password=123456 5 initialSize=0 6 #定义最大连接数 7 maxActive=20 8 #定义最大空闲 9 maxIdle=20 10 #定义最小空闲 11 minIdle=1 12 #定义最长等待时间 13 maxWait=60000
5、运行截图
首页
买家购物车
买家账单
卖家发布商品界面
标签:adsi ring mysq one style 注册 handler work 处理器
原文地址:http://www.cnblogs.com/shenzhi/p/7590973.html