Spring學(xué)習(xí)基礎(chǔ)---配置文件_JSP教程
教程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
相關(guān)JSP教程:
- jsp response.sendRedirect不跳轉(zhuǎn)的原因分析及解決
- JSP指令元素(page指令/include指令/taglib指令)復(fù)習(xí)整理
- JSP腳本元素和注釋復(fù)習(xí)總結(jié)示例
- JSP FusionCharts Free顯示圖表 具體實(shí)現(xiàn)
- 網(wǎng)頁(yè)模板:關(guān)于jsp頁(yè)面使用jstl的異常分析
- JSP頁(yè)面中文傳遞參數(shù)使用escape編碼
- 基于jsp:included的使用與jsp:param亂碼的解決方法
- Java Web項(xiàng)目中連接Access數(shù)據(jù)庫(kù)的配置方法
- JDBC連接Access數(shù)據(jù)庫(kù)的幾種方式介紹
- 網(wǎng)站圖片路徑的問(wèn)題:絕對(duì)路徑/虛擬路徑
- (jsp/html)網(wǎng)頁(yè)上嵌入播放器(常用播放器代碼整理)
- jsp下顯示中文文件名及絕對(duì)路徑下的圖片解決方法
JSP教程Rss訂閱編程教程搜索
JSP教程推薦
- Jsp中使用FCKeditor上傳圖片
- Spring學(xué)習(xí)基礎(chǔ)---與Struts整合
- JAVA實(shí)現(xiàn)數(shù)據(jù)庫(kù)基本操作指南
- J2ME中使用記錄存儲(chǔ)系統(tǒng)RMS存儲(chǔ)信息
- 解決jsp重復(fù)提交
- JSP自定義標(biāo)簽Taglib實(shí)現(xiàn)過(guò)程重點(diǎn)總結(jié)
- JSP教程之java讀取文本文件內(nèi)容并獲取文件大小
- JSP初級(jí)教程之跟我學(xué)JSP(四)
- CNET JSP BASIC 簡(jiǎn)介
- J2ME開(kāi)發(fā)工具EclipseME 1.2.1新版發(fā)布
- 相關(guān)鏈接:
- 教程說(shuō)明:
JSP教程-Spring學(xué)習(xí)基礎(chǔ)---配置文件
。