1.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:context="http://www.springframework.org/schema/context"xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"><description>Spring公共配置</description><!-- 配置Spring上下文的注解 --><context:annotation-config/><!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 --><context:component-scan base-package="com"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><!-- 属性文件位置 --><context:property-placeholder location="classpath:*.properties"/><!--数据源配置--><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><property name="driverClassName" value="${jdbc.driver}"/><property name="url" value="${jdbc.url}"/><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="packagesToScan" value="com.entity"/><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.format_sql}</prop><prop key="hibernate.useUnicode">${hibernate.useUnicode}</prop><prop key="hibernate.characterEncoding">${hibernate.characterEncoding}</prop><prop key="current_session_context_class">thread</prop></props></property></bean><!-- 使用annotation定义事务 --><bean id="transactionManager"class="org.springframework.orm.hibernate5.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"/></bean><tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
</beans>

2. spring-mvc.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:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 自动扫描且只扫描@Controller --><context:component-scan base-package="com.controller"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><mvc:annotation-driven/>
<!--    静态资源文件,不需要通过D****Servleet--><mvc:resources location="/static/" mapping="/static/**"/><!-- 文件上传 --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></bean><!-- 定义JSP文件的位置 --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/"/><property name="suffix" value=".jsp"/></bean>
</beans>

3.web.xml的配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"id="WebApp_ID" version="3.1"><display-name>cakessh</display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><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>-->
<!--        -->
<!--    <context-param>-->
<!--        <param-name>contextConfigLocation</param-name>-->
<!--        <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>-->
<!--    </context-param>--><servlet><servlet-name>springmvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springmvc</servlet-name><url-pattern>/</url-pattern></servlet-mapping><filter><filter-name>CharacterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>utf-8</param-value></init-param></filter><filter-mapping><filter-name>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><filter><filter-name>openSessionInView</filter-name><filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping><filter-name>openSessionInView</filter-name><url-pattern>/*</url-pattern></filter-mapping>
</web-app>

一些关于数据库的配置 dbinfo.properties

#mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/test2?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=#hibernate
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.format_sql=false
hibernate.useUnicode=true
hibernate.characterEncoding=utf-8

Spring+hibernate+JSP实现Piano的数据库操作---4.配置文件相关推荐

  1. Spring+hibernate+JSP实现Piano的数据库操作---1.目录结构+展示

    目录结构 界面

  2. Spring Boot:使用p6spy监控数据库操作

    最近因为换工作的原因导致博客停更好久,感觉再不写点什么就要废掉了_(:з」∠*)_ 首先p6spy是一个开源的数据库监控插件,我们能通过使用p6spy打印数据库操作或者保存操作日志. 首先放上p6sp ...

  3. hibernate版本_基于jsp+mysql+Spring+hibernate+Struts 2的SSH在线蛋糕销售网站平台管理系统...

    运行环境: 最好是java jdk 1.8,我们在这个平台上运行的.其他版本理论上也可以.IDE环境: Eclipse,Myeclipse,IDEA都可以tomcat环境: Tomcat 7.x,8. ...

  4. 关于struts,spring,hibernate的几个问题

    Struts2: 1.为什么每次请求都要创建一个Action对象? re: 为了防止线程迸发,如果每次都使用同一个Action进行数据修改和传递的话,容易引起线程迸发,使线程不安全. 2.ModelD ...

  5. SSH框架(Struts+Spring+Hibernate)

    在SSH 的组合框架模式中,三者各自的作用? Struts 是一个很好的MVC框架,主要技术是Servlet和Jsp.Struts的MVC设计模式可以使我们的逻辑变得很清晰,让我们写的程序层次分明.基 ...

  6. Spring之数据库操作

    本文主要包括以下内容 spring+jdbc数据库操作 spring+jdbc声明事务处理 spring+hibernate声明事务处理 spring+jdbc数据库操作 方法 1.让自己写的一个da ...

  7. spring boot数据库操作汇总

    1 关于orm orm即object relational mapping,对象关系映射,即将数据库中的表映射成对象. 常用的orm有以下: mybatis spring jdbc template ...

  8. 基于jsp+mysql+Spring+hibernate+在线学习交流论坛平台

    本项目演示链接地址 > 主要功能模块设计: 管理员角色包含以下功能:管理员登录,发布公告,修改资料,查看新帖,查看精华帖请求,封锁用户,创建讨论区等功能. 用户角色包含以下功能:按分类查看,用户 ...

  9. 基于jsp+mysql+Spring+hibernate+的SSH在线学习交流论坛平台

    本项目演示链接地址> 主要功能模块设计: 管理员角色包含以下功能:管理员登录,发布公告,修改资料,查看新帖,查看精华帖请求,封锁用户,创建讨论区等功能. 用户角色包含以下功能:按分类查看,用户登 ...

最新文章

  1. php和python哪个工资高-python和php哪个更有前景
  2. 引用数据类型的深拷贝
  3. 11 个 Linux 上最佳的图形化 Git 客户端
  4. 轻松查看Internet Explorer缓存文件
  5. spring mvc 教程_Spring MVC开发–快速教程
  6. c语言linux TCP长连接 socket收发范例 断开自动重连
  7. 热传递物理模型matlab,简单传热学计算机分析MatlabPDE二维不稳态焊接热传导求解.PPT...
  8. qtreewidget点击空白处时取消以选项_手机APP自动续费,我们要如何取消?
  9. python编程入门 适合于零基础朋友-Python不能帮你找到女朋友,却能让你成为有钱的单身狗。...
  10. [转载] Python 字典(Dictionary) get()方法
  11. java实战 ——分类模块的开发
  12. shopex 小知识
  13. python 递归函数例子
  14. Cisco ASA 9.17.1 Full ( bin, ova, qcow2, SPA, vhdx ) 下载 - 思科防火墙
  15. 论运营型CRM和分析型CRM
  16. 2020年回顾,这一年,不容易
  17. LeetCode No5. 最长回文子串 题解
  18. UE4场景流程规范-纹理压缩(美术版/程序版/太长不看版)
  19. Windows Server 2016 NTP服务端和客户端配置
  20. IOS应用内及应用之间跳转URL

热门文章

  1. spring boot / cloud (二十) 相同服务,发布不同版本,支撑并行的业务需求
  2. JavaScript数组快速入门
  3. JVM指令集(指令码、助记符、功能描述)(转)
  4. 如何设置硬盘安装linux,linux用硬盘安装时所设置选项
  5. 【微软的VDI】Windows Server 2012 RDS存储相关
  6. hive使用适用场景_数据分析之hive学习(四):面试题——场景输出(row_number)...
  7. ORA-01078: failure in processing system parameters
  8. html如何把三个按键放一起_winkawaks使用手柄按键玩游戏的教程-winkawaks街机模拟器用手柄攻略...
  9. python透明图片合并_如何使用PIL将透明png图像与另一个图像合并
  10. html字体代码_第50天 HTML和css的学习