Using the SSH framework for user login verification
Source: Internet
Author: User
Today, write a very simple example of user login verification through struts+hibernate+spring integration, and let us know how the three are integrated. We can build the corresponding environment through the MyEclipse Wizard, if you use the wizard to add SSH project support, we will remember that we added the order of spring,hibernate,struts, I do not say here how to add through the wizard, I will direct the source code to everyone, you can write according to the source code. First: Configuration of the Applicationcontext.xml file <?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:tx= "Http://www.springframework.org/schema/tx"
Xsi:schemalocation= "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/ Spring-beans-2.0.xsd
Http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">
<!--defining data sources--
<bean id= "DataSource"
class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname"
Value= "Com.mysql.jdbc.Driver" >
</property>
<property name= "url"
Value= "Jdbc:mysql://192.168.1.90:3306/testdb" >
</property>
<property name= "username" value= "root" ></property>
<property name= "Password" value= "hanxue123" ></property>
</bean>
<!--definition using hibernate--
<bean id= "Sessionfactory"
class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" >
<ref bean= "DataSource"/>
</property>
<property name= "Hibernateproperties" >
<props>
<prop key= "Hibernate.dialect" >
Org.hibernate.dialect.MySQLDialect
</prop>
<prop key= "Hibernate.show_sql" >true</prop>
</props>
</property>
<!--define mapped files--
<property name= "Mappingresources" >
<value>User.hbm.xml</value>
</property>
</bean>
<!--configuration Transaction Manager-
<bean id= "TransactionManager" class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" >
<ref bean= "Sessionfactory"/>
</property>
</bean>
<!--The propagation characteristics of a configuration transaction-
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "find*" propagation= "REQUIRED"/>
<tx:method name= "save*" propagation= "REQUIRED"/>
<tx:method name= "del*" propagation= "REQUIRED"/>
<tx:method name= "modify*" propagation= "REQUIRED"/>
<tx:method name= "update*" propagation= "REQUIRED"/>
<tx:method name= "*" propagation= "REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--configure which classes of which methods participate in the transaction--
<aop:config>
<aop:pointcut id= "Allmanagermethod" expression= "Execution (* com.han.*.*.* (..))" />
<aop:advisor pointcut-ref= "Allmanagermethod" advice-ref= "Txadvice"/>
</aop:config>
<!--inject the business logic object through spring into the action, avoiding direct code query in the action class--
<bean id= "Loginservice" class= "Com.han.service.LoginServiceImpl" >
<property name= "Sessionfactory" ref= "Sessionfactory" ></property>
</bean>
<bean name= "/logina" class= "Com.han.action.LoginA" scope= "prototype" >
<property name= "Loginservice" ref= "Loginservice" ></property>
</bean>
</beans> Second: Configuration of the User.hbm.xml file, defining the mapping to the database <?xml version= "1.0"?>
<! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<comment>users may bid for or sell auction items.</comment>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service