日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

struts2+spring3+hibernate3+mysql简单登录实现

發(fā)布時間:2023/12/10 数据库 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 struts2+spring3+hibernate3+mysql简单登录实现 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.導(dǎo)入相關(guān)的jar包

2.建立數(shù)據(jù)庫

1 create table account( 2 id int(10), 3 user varchar(50), 4 paw varchar(50) 5 ); 6 insert into account values(1,'admin','admin');

?

3.建立包結(jié)構(gòu)

?

4.配置文件的配置及代碼

4.1 數(shù)據(jù)庫配置文件:db.properties

1 #jdbc 2 jdbc.driver=com.mysql.jdbc.Driver 3 jdbc.url=jdbc:mysql://127.0.0.1:3306/test 4 jdbc.username=root 5 jdbc.password=

4.2 spring配置文件:applicationContext.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" xmlns:context="http://www.springframework.org/schema/context" 4 xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee" 5 xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" 6 xmlns:mvc="http://www.springframework.org/schema/mvc" 7 xsi:schemaLocation=" 8 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 9 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd 10 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd 11 http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd 12 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 13 http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd 14 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> 15 <context:component-scan base-package="ssh.ft"></context:component-scan> 16 17 <context:property-placeholder location="classpath:configs/db.properties" /> 18 <!-- datasource --> 19 <bean id="dataSource" 20 class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 21 <property name="driverClassName" value="${jdbc.driver}" /> 22 <property name="url" value="${jdbc.url}" /> 23 <property name="username" value="${jdbc.username}" /> 24 <property name="password" value="${jdbc.password}" /> 25 </bean> 26 <!-- spring與hibernate整合 spring來管理session的創(chuàng)建、打開和關(guān)閉 --> 27 <bean id="sessionFactory" 28 class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 29 <!-- 通過配置文件的方式獲取數(shù)據(jù)源,出現(xiàn)異常,未解決 --> 30 <property name="hibernateProperties"> 31 <props> 32 <prop key="connection.useUnicode">true</prop> 33 <prop key="connection.characterEncoding">utf-8</prop> 34 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> 35 <prop key="hibernate.show_sql">true</prop> 36 <prop key="hibernate.hbm2ddl.auto">update</prop> 37 </props> 38 </property> 39 <property name="dataSource" ref="dataSource" /> 40 <property name="mappingResources"> 41 <list> 42 <!-- 以下用來列出所有的PO映射文件 --> 43 <value>configs/account.hbm.xml</value> 44 </list> 45 </property> 46 </bean> 47 <!-- 定義事物管理器,并位事物管理器配置上述所定義的session --> 48 <!-- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 49 <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> 50 </bean> <tx:annotation-driven transaction-manager="transactionManager"/> --> 51 52

轉(zhuǎn)載于:https://www.cnblogs.com/Jansens520/p/6504686.html

總結(jié)

以上是生活随笔為你收集整理的struts2+spring3+hibernate3+mysql简单登录实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。