随笔心得

记我所见,记我所想

BlogJava 首页 新随笔 联系 聚合 管理
  34 Posts :: 0 Stories :: 16 Comments :: 0 Trackbacks

Web.xml

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

< web-app version = "2.4"

    xmlns = "http://java.sun.com/xml/ns/j2ee"

    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee

    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

 

<! 自动加载一个以 GOpreation 开头的xml文件 à

    < servlet >

       < servlet-name > GOpreation </ servlet-name >

       < servlet-class > org.springframework.web.servlet.DispatcherServlet </ servlet-class >

       < load-on-startup > 1 </ load-on-startup >

    </ servlet >

    < servlet-mapping >

        < servlet-name > GOpreation </ servlet-name >

        < url-pattern > *.shtml </ url-pattern >

    </ servlet-mapping >

    < jsp-config >

 

<! 注册spring 标签-->

       < taglib >

            < taglib-uri > /spring </ taglib-uri >

            < taglib-location > /WEB-INF/spring.tld </ taglib-location >

        </ taglib >

   </ jsp-config >

 

<! 设置 session 有效期- à

    < session-config >   

        < session-timeout > 60 </ session-timeout >   

    </ session-config >

 

</ web-app >

 

 

  GOpreation -servlet.xml

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

<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >

 

< beans >

 

<! class中的类去读取value中的资源文件-->

    < bean id = "propertyConfigurer" class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >

        < property name = "location" value = "/WEB-INF/jdbc.properties" />

    </ bean >

 

<! 定义数据源,该beanID dataSource -->

    < bean id = "dataSource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" >

        < property name = "driverClassName" value = "${jdbc.driverClassName}" />

        < property name = "url" value = "${jdbc.url}" />

        < property name = "username" value = "${jdbc.username}" />

        < property name = "password" value = "${jdbc.password}" />

 

    </ bean >

 

<!- 定义HibernateSessionFactory- à

    < bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" >

 

<! 依赖注入数据源,注册的正式上文定义的dataSource-->

        < property name = "dataSource" ref = "dataSource" />

 

<! mappingResource 属性用来列出全部映射文件 >

        < property name = "mappingResources" >

            < list >

 

<! 以下用来列出所有的PO(Persistent Object持久化对象)映射文件-->

                < value > gos/hzyg/hdgos/model/Ahouse.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RinRoomFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/MoldBuildList.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Acompany.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Soperator.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RinRepair.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RbuildFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/ClendType.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Chut.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AroomLevel.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/CstructType.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Danalysis.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RinStuctHouseSum.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/CstructForm.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/MsumTable.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AroomFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/MbuildList.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RroomFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Cunit.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/CownerType.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/MroomList.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AroomCheck.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RinBuildFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RinHouseSum.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/CdamageGrade.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AbuildLevel.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Dtproperties.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AbuildSelfFix.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AbuildCheck.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/ChouseUse.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/CbuildAge.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RhouseSumStruct.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/RhouseSum.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Rrepair.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Zpara.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/Carea.hbm.xml </ value >

                < value > gos/hzyg/hdgos/model/AbuildSubCheck.hbm.xml </ value >

            </ list >

        </ property >

 

<!- 定义HibernateSessionFactory的属性- à

 

        < property name = "hibernateProperties" >

            < props >

 

<! 指定 hibernate 的连接方言 >

                < prop key = "hibernate.dialect" > ${hibernate.dialect} </ prop >

 

<! 指定是否打印sql语句 >

                < prop key = "hibernate.show_sql" > true </ prop >

 

<! 待定以后补充 >

                < prop key = "hibernate.generate_statistics" > true </ prop >

            </ props >

        </ property >


     <
property name = "eventListeners" >

       < map >

          < entry key = "merge" >

           < bean class = "org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />

         </ entry >

       </ map >

      </ property >

</ bean >

    < bean id = "viewResolver" class = "org.springframework.web.servlet.view.InternalResourceViewResolver" >

        < property name = "prefix" >< value > /WEB-INF/view/ </ value ></ property >

        < property name = "suffix" >< value > .jsp </ value ></ property >

    </ bean >

   

<!-- urlMapping Space -->   

    < bean id = "urlMapping" class = "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >

        < property name = "mappings" >

          < props >

            <!-- 邓毅TEST -->

              < prop key = "/test.shtml" > testController </ prop >

            <!-- 邓毅TEST end -->

           

              < prop key = "/seculist.shtml" > secuController </ prop >

              < prop key = "/chutlist.shtml" > chutController </ prop >

              < prop key = "/addhouse.shtml" > addhouController </ prop >

              < prop key = "/inserhouse.shtml" > inserhouseController </ prop >

              < prop key = "/buildlist.shtml" > BuildingListController </ prop >

              <!-- 任喜海 start -->

              < prop key = "/aroomlevellist.shtml" > AroomLeveListController </ prop >

              <!-- 任喜海 end -->

               

          </ props >

        </ property >

    </ bean >

<!-- urlMapping Space End-->

 

<!-- *********************************************************  -->

 

<!-- Dao Space -->

    <!-- 邓毅TEST -->

    < bean id = "testDao" class = "gos.hzyg.hdgos.TEST.TestSql" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    <!--  邓毅TEST end -->

   

    < bean id = "cuDao" class = "gos.hzyg.hdgos.dao.imp.secu.CunitDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

   

    < bean id = "ahDao" class = "gos.hzyg.hdgos.dao.imp.secu.AhouseDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "chDao" class = "gos.hzyg.hdgos.dao.imp.secu.ChutDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "csfDao" class = "gos.hzyg.hdgos.dao.imp.secu.CstructFormDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "cstDao" class = "gos.hzyg.hdgos.dao.imp.secu.CstructTypeDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "cwtDao" class = "gos.hzyg.hdgos.dao.imp.secu.CownerTypeDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "cltDao" class = "gos.hzyg.hdgos.dao.imp.secu.ClendTypeDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "cbaDao" class = "gos.hzyg.hdgos.dao.imp.secu.CbuildAgeDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    < bean id = "AbuildDao" class = "gos.hzyg.hdgos.dao.imp.secu.AbuildDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

    <!-- add by renxh -->

    < bean id = "arDao" class = "gos.hzyg.hdgos.dao.imp.secu.AroomLevelDaoImp" >

        < property name = "sessionFactory" >

            < ref local = "sessionFactory" />

        </ property >

    </ bean >

   

    <!-- renxh end -->

<!-- Dao Space End-->

 

<!-- *********************************************************  -->

 

<!-- Controller Space -->

    <!--  邓毅TEST -->

    < bean id = "testController" class = "gos.hzyg.hdgos.TEST.Test" >

        < property name = "listview" >

            < value > test </ value >

        </ property >

        < property name = "testDao" >

            < ref local = "testDao" />

        </ property >

    </ bean >

 

    <!--  邓毅TEST end -->

   

    < bean id = "secuController" class = "gos.hzyg.hdgos.action.secu.SecuListController" >

        < property name = "listview" >

            < value > secu/seculist </ value >

        </ property >

        < property name = "cuDao" >

            < ref local = "cuDao" />

        </ property >

        < property name = "ahDao" >

            < ref local = "ahDao" />

        </ property >

    </ bean >

    < bean id = "chutController" class = "gos.hzyg.hdgos.action.secu.ChutListController" >

        < property name = "listview" >

            < value > secu/chutlist </ value >

        </ property >

        < property name = "chDao" >

            < ref local = "chDao" />

        </ property >

    </ bean >

    < bean id = "addhouController" class = "gos.hzyg.hdgos.action.secu.AddhouseController" >

       < property name = "listview" >

            < value > secu/addhouse </ value >

        </ property >

        < property name = "csfDao" >

            < ref local = "csfDao" />

        </ property >

        < property name = "cstDao" >

            < ref local = "cstDao" />

        </ property >

        < property name = "cwtDao" >

            < ref local = "cwtDao" />

        </ property >

        < property name = "cltDao" >

            < ref local = "cltDao" />

        </ property >

        < property name = "cbaDao" >

            < ref local = "cbaDao" />

        </ property >

    </ bean >

    < bean id = "inserhouseController" class = "gos.hzyg.hdgos.action.secu.InserhouseController" >

        < property name = "listview" >

            < value > secu/addhouse </ value >

        </ property >

        < property name = "ahDao" >

            < ref local = "ahDao" />

        </ property >

    </ bean >

    < bean id = "BuildingListController" class = "gos.hzyg.hdgos.action.secu.buildlist.BuildingListController" >

        < property name = "listview" >

            < value > secu/buildinglist </ value >

        </ property >

        < property name = "ahDao" >

            < ref local = "AbuildDao" />

        </ property >

    </ bean >

   

    <!-- add by renxh -->

   

    < bean id = "AroomLeveListController" class = "gos.hzyg.hdgos.action.secu.AroomLeveListController" >

        < property name = "listview" >

            < value > secu/bungalowws </ value >

        </ property >

        < property name = "arDao" >

            < ref local = "arDao" />

        </ property >

   

    </ bean >

   

    <!-- renxh end -->

 

 

<!-- Controller Space End -->

 

</ beans >

posted on 2007-04-29 10:33 源自有缘 阅读(498) 评论(1)  编辑  收藏

Feedback

# re: 初学 hibernate + spring 记录 2007-04-29 16:37 源自有缘
dao

package gos.hzyg.hdgos.dao.secu;

import java.util.List;

/**
* @author renxh
* 针对平房完损等级评定做的接口
*/
public interface AroomLevelDao {

/**
* 方法 getAllaRoomLevel()
* 查询所有的相关信息
* @param cAreaid
*
*/
List getAllaRoomLevel();

}

接口实现

/**
* 作者:任喜海2007-4-27
*/
package gos.hzyg.hdgos.dao.imp.secu;

import java.util.List;

import gos.hzyg.hdgos.dao.secu.AroomLevelDao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* @author renxh
*
*/
public class AroomLevelDaoImp extends HibernateDaoSupport implements
AroomLevelDao {

public List getAllaRoomLevel() {
// TODO 自动生成方法存根
Session session = this.getSession();
Query query = null;
String hql = "from AroomLevel where 1=1";

query = session.createQuery(hql);
List info = query.list();


return info;
}

}

对应的controller

/**
* 作者:任喜海2007-4-28
*/
package gos.hzyg.hdgos.action.secu;

import java.util.List;

import gos.hzyg.hdgos.dao.secu.AroomLevelDao;
import gos.hzyg.hdgos.dao.secu.ChutDao;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
* @author renxh
*
*/
public class AroomLeveListController implements Controller{

private String listview;
private AroomLevelDao arDao;



public AroomLevelDao getArDao() {
return arDao;
}

public void setArDao(AroomLevelDao arDao) {
this.arDao = arDao;
}

public String getListview() {
return listview;
}

public void setListview(String listview) {
this.listview = listview;
}

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO 自动生成方法存根
System.out.println("@@@@@aRoomLevel@@@@@@@");

List chinfo = arDao.getAllaRoomLevel();//取得所有平房信息


HttpSession s=request.getSession();
s.setAttribute("chinfo", chinfo);

System.out.println("@@@@@III@@@@@@@");

return new ModelAndView(this.getListview());
}



}
  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: