隨筆心得

          記我所見,記我所想

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            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

          ??? >

          ?

          <! 自動(dòng)加載一個(gè)以 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 >

          ?

          <! 注冊(cè)spring 標(biāo)簽-->

          ?????? < taglib >

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

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

          ??????? </ taglib >

          ?? </ jsp-config >

          ?

          <! 設(shè)置 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 >

          ?

          <! 定義數(shù)據(jù)源,該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" >

          ?

          <! 依賴注入數(shù)據(jù)源,注冊(cè)的正式上文定義的dataSource-->

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

          ?

          <! mappingResource 屬性用來列出全部映射文件 >

          ??????? < property name = "mappingResources" >

          ??????????? < list >

          ?

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

          ??????????????? < 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 >

          ?

          <! 待定以后補(bǔ)充 >

          ??????????????? < 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 >


          Feedback

          # re: 初學(xué) hibernate + spring 記錄 2007-04-29 16:37 源自有緣
          dao

          package gos.hzyg.hdgos.dao.secu;

          import java.util.List;

          /**
          * @author renxh
          * 針對(duì)平房完損等級(jí)評(píng)定做的接口
          */
          public interface AroomLevelDao {

          /**
          * 方法 getAllaRoomLevel()
          * 查詢所有的相關(guān)信息
          * @param cAreaid
          *
          */
          List getAllaRoomLevel();

          }

          接口實(shí)現(xiàn)

          /**
          * 作者:任喜海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 自動(dòng)生成方法存根
          Session session = this.getSession();
          Query query = null;
          String hql = "from AroomLevel where 1=1";

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


          return info;
          }

          }

          對(duì)應(yīng)的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 自動(dòng)生成方法存根
          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());
          }



          }
            回復(fù)  更多評(píng)論
            


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 开鲁县| 育儿| 松潘县| 西贡区| 望谟县| 西藏| 丽江市| 灵宝市| 山西省| 澳门| 眉山市| 竹北市| 平度市| 张北县| 炉霍县| 马关县| 翁牛特旗| 海伦市| 双辽市| 永泰县| 武宁县| 泰来县| 原平市| 竹北市| 新龙县| 崇仁县| 阜平县| 卢龙县| 收藏| 汝城县| 通榆县| 渭南市| 衡阳市| 集安市| 嘉禾县| 理塘县| 乌拉特前旗| 临泽县| 闽清县| 政和县| 梧州市|