日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

Spring學(xué)習(xí)基礎(chǔ)---配置文件_JSP教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:Spring學(xué)習(xí)基礎(chǔ)---多框架集成
ApplicationContextctx 1,定義資源文件獲得資源文件的消息,國(guó)際化信息 beanid=messageResourceclass=org.springFramework.context.support.ResourceBoundleMessageSource propertyname=basenames xxxx /property /bean 將會(huì)搜索xxxx.properties,xxxx_

1,配置文件的配置頭
<?xml version="1.0" encoding="UTF-8"?>

<!--
  - Application context definition for JPetStore’s business layer.
  - Contains bean references to the transaction manager and to the DAOs in
  - dataAccessContext-local/jta.xml (see web.xml’s "contextConfigLocation").
  -->
<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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
這樣寫(xiě)才對(duì)

2,配置文件可以使用多個(gè)屬性文件
<!-- Configurer that replaces ${...} placeholders with values from properties files -->
 <!-- (in this case, mail and JDBC related properties) -->
 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>WEB-INF/mail.properties</value>
    <value>WEB-INF/jdbc.properties</value>
   </list>
  </property>
 </bean>
類是框架的。
里面包含兩個(gè)屬性文件,屬性文件里都是“key=value”這種形式的。這樣配置文件里就可以使用屬性文件里的key,使用方法
${key},這樣轉(zhuǎn)移出屬性設(shè)置,維護(hù)起來(lái)比較方便。

3,定義Validator供web層使用,自定義類。
<bean id="accountValidator" class="org.springframework.samples.jpetstore.domain.logic.AccountValidator"/>
類里面使用了ValidatorUtils系統(tǒng)類來(lái)進(jìn)行處理。

4,服務(wù)層的定義。
 PetStoreImpl定義在配置文件中,是自己的類。
 所有的DAO都是它的屬性,注意,DAO是interface,而不是class.
 PetStoreImpl中定義了所有的DAO接口作為屬性,定義了他們的set方法,但是沒(méi)有定義get方法。
 這樣所有的業(yè)務(wù)操作就可以不用管DAO是如何實(shí)現(xiàn)的了,而只管使用這個(gè)PetStoreImpl就好了。

 DAO都是接口這種做法與平時(shí)開(kāi)發(fā)不一樣,我以前使用hibernate生成工具生成的dao都是默認(rèn)好的實(shí)現(xiàn)類。
 而此處的DAO卻都是接口。他們的實(shí)現(xiàn)方法是這樣的:
 interface PetStoreFacade { } //定義所有的業(yè)務(wù)方法。
 interface AccountDao{} //定義所有帳戶的業(yè)務(wù)方法。
 interface CategoryDao{} //定義類別的業(yè)務(wù)方法。
 interface ProductDao{} //定義產(chǎn)品的業(yè)務(wù)方法。
 。。。其他DAO接口,定義自己的業(yè)務(wù)方法。
 class PetStoreImpl implements PetStoreFacade //這個(gè)類就是一個(gè)javabean,操作的都是接口。
 //定義所有DAO接口當(dāng)作自己的屬性。
 //實(shí)現(xiàn)set方法
 //實(shí)現(xiàn)PetStoreFacade 定義的業(yè)務(wù)接口,實(shí)現(xiàn)的時(shí)候調(diào)用DAO接口的方法。

 如果是我自己,那么就會(huì)定義IDAO當(dāng)作接口,因?yàn)閔ibernate插件自動(dòng)生成dao類,容易混淆。
 

分享:JSP初級(jí)教程之跟我學(xué)JSP(八)
第八章Blob類型數(shù)據(jù)的存取和使用第一個(gè)Servlet—— 圖片文件的操作 以下是我經(jīng)過(guò)改編得到的 jsp 代碼: ------------------------------upphoto.htm------------------------------------ html head metahttp-equiv=Content-Typecontent=text/html;charse

共4頁(yè)上一頁(yè)1234下一頁(yè)
來(lái)源:模板無(wú)憂//所屬分類:JSP教程/更新時(shí)間:2010-03-08
相關(guān)JSP教程