5.spring+struts+hibernate Configuration file Consolidation

Source: Internet
Author: User

One: Configuration file consolidation ssh

1. Create a mapping file for Hibernate entity classes, typically placed under the resource folder

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!--Create a mapping file--
<class name= "Cn.yunhe.model.User" table= "User" >
<id name= "id" column= "id" type= "Java.lang.Integer" >
<generator class= "native"/>

<property name= "name" type= "java.lang.String"/>
<property name= "pwd" type= "java.lang.String"/>
<property name= "Age" type= "Java.lang.Integer"/>

Configuration of the 2.struts.xml file

<?xml version= "1.0" encoding= "UTF-8"?>

<! DOCTYPE Struts Public
"-//apache software foundation//dtd Struts Configuration 2.3//en"
"Http://struts.apache.org/dtds/struts-2.3.dtd" >

<!--struts Method configuration-
<constant name= "Struts.devmode" value= "true"/>
<!--allow dynamic method calls--
<constant name= "Struts.enable.DynamicMethodInvocation" value= "true"/>

<package name= "My" extends= "Struts-default" >

<action name= "user" class= "useraction" >//the bean created in the spring file





Configuration of 3.Spring files

<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
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.xsd ">

<!--data Source-
<bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" >

<property name= "Driverclass" value= "Com.mysql.jdbc.Driver"/>
<property name= "Jdbcurl" value= "Jdbc:mysql://localhost:3306/test"/>
<property name= "User" value= "root"/>
<property name= "Password" value= "076634"/>

<!--Create Session factory--
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" ref= "DataSource"/>

<property name= "Mappingresources" >

<!--define things manager (declare things)--
<bean id= "TransactionManager" class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >

<property name= "Sessionfactory" ref= "Sessionfactory"/>
<!--durable layers--
<bean id= "Userdao" class= "Cn.yunhe.dao.UserDaoImpl" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>

<!--business Layer--
<bean id= "userbiz" class= "Cn.yunhe.biz.UserBizImpl" >
<property name= "Userdao" ref= "Userdao"/>

<!--control Layer--
<bean id= "useraction" class= "Cn.yunhe.controller.UserController" >
<property name= "userbiz" ref= "userbiz"/>


Configuration of the 4.web.xml

<display-name>archetype Created Web application</display-name>


<!--struts Filters--


<!--spring Listener to create a spring container when the system is started--

5.spring+struts+hibernate Configuration file Consolidation

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.