锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久91亚洲精品中文字幕,亚洲AV永久无码精品一福利,亚洲中文字幕无码久久精品1http://m.tkk7.com/rory/category/9611.htmlHappy study,Happy work,Happy lifezh-cnTue, 27 Feb 2007 12:36:04 GMTTue, 27 Feb 2007 12:36:04 GMT60SpringXmlrpcServiceExporter for xmlrpc3.xhttp://m.tkk7.com/rory/archive/2006/10/22/spring_xmlrpc3_service_exporter.html鑾鑾Sun, 22 Oct 2006 08:12:00 GMThttp://m.tkk7.com/rory/archive/2006/10/22/spring_xmlrpc3_service_exporter.htmlhttp://m.tkk7.com/rory/comments/76628.htmlhttp://m.tkk7.com/rory/archive/2006/10/22/spring_xmlrpc3_service_exporter.html#Feedback0http://m.tkk7.com/rory/comments/commentRss/76628.htmlhttp://m.tkk7.com/rory/services/trackbacks/76628.html聽聽聽聽聽聽鎴戜滑鐨勯」鐩敤鍒頒簡(jiǎn)xmlrpc,涓嶈繃榪樻槸鐢ㄧ殑2.x鐗堟湰鐨勩傜敱浜巟mlrpc3.x鍦版帹鍑恒傛彁渚涗簡(jiǎn)NULL,Serializable絳夌殑鏀寔錛屽皢鍘熸潵鐨凥ashtable鏀規(guī)垚浜?jiǎn)Map,Vector鏀規(guī)垚浜?jiǎn)List銆傞兘鏄笉閿欑殑榪涙銆傛墍浠ユ垜浠喅瀹氫粠xmlrpc2.x鍗囩駭鍒皒mlrpc3.x.
聽聽聽聽聽聽鍦╯pring閲岄潰鏈夊嚑涓猄erviceExporter錛宱rg.springframework.remoting.rmi.RmiServiceExporter銆乷rg.springframework.remoting.caucho.HessianServiceExporter銆乷rg.springframework.remoting.caucho.BurlapServiceExporter銆備笉榪囨病鏈墄mlrpc鐨剆erviceExporter錛屽師鏉ユ垜浠槸鑷繁灝佽鐨刋mlRpcServer,鐢╯ervlet鎻愪緵鏈嶅姟銆?eg:http://localhost:8080/community/service/xmlrpc)娌℃湁鍜宻pring闆嗘垚铏界劧鐢ㄤ簡(jiǎn)spring銆?br />聽聽聽 鑰冭檻鍒皊pring鐨勪究鍒╀互鍙?qiáng)閰嵕|殑鍚屾剰鎴戝喅瀹氬皢xmlrpcService鏀懼叆spring涓倄mlrpc3.x鍜寈mlrpc2.x鐨勪唬鐮佸熀鏈笂娌℃湁涓鏍風(fēng)殑銆傛敼浜?jiǎn)寰堝涓滆パ潃傞櫎浜?jiǎn)绫诲瀷鍙樺寲涔嬪锛寴q樻坊鍔犱簡(jiǎn)瀵瑰紓甯哥殑鏀寔銆傝緇嗕俊鎭鍙傜収xmlrpc3.x婧愪唬鐮併?br />XmlRpcServiceExporter.java

package 聽com.jdkcn.xmlrpc;

import 聽javax.servlet.ServletException;

/**
聽*聽
@author 聽<a聽href="mailto:rory.cn@gmail.com">somebody</a>
聽*聽
@since 聽2006-9-27聽03:59:22聽pm
聽*聽
@version 聽$Id聽XmlRpcServiceExporter.java$
*/
public class 聽XmlRpcServiceExporter聽 extends 聽RemoteExporter聽 implements
聽聽聽聽聽聽聽聽Controller,聽I(yíng)nitializingBean聽{
聽聽聽聽
聽聽聽聽
private 聽XmlRpcServletServer聽server;
聽聽聽聽
聽聽聽聽
public 聽String聽serviceName;
聽聽聽聽
聽聽聽聽
public 聽Resource聽configFile;
聽聽聽聽
聽聽聽聽
public 聽Boolean聽enabledForExtensions;
聽聽聽聽
聽聽聽聽
public void 聽setEnabledForExtensions(Boolean聽enabledForExtensions)聽{
聽聽聽聽聽聽聽聽
this .enabledForExtensions聽 = 聽enabledForExtensions;
聽聽聽聽}

聽聽聽聽
public void 聽setConfigFile(Resource聽configFile)聽{
聽聽聽聽聽聽聽聽
this .configFile聽 = 聽configFile;
聽聽聽聽}

聽聽聽聽
public 聽String聽getServiceName()聽{
聽聽聽聽聽聽聽聽
return 聽serviceName;
聽聽聽聽}

聽聽聽聽
public void 聽setServiceName(String聽serviceName)聽{
聽聽聽聽聽聽聽聽
this .serviceName聽 = 聽serviceName;
聽聽聽聽}

聽聽聽聽
public 聽XmlRpcServletServer聽getXmlRpcServletServer()聽{
聽聽聽聽聽聽聽聽
return 聽server;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
/* 聽(non-Javadoc)
聽聽聽聽聽*聽@see聽org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest,聽javax.servlet.http.HttpServletResponse)
聽聽聽聽聽
*/
聽聽聽聽
public 聽ModelAndView聽handleRequest(HttpServletRequest聽request,
聽聽聽聽聽聽聽聽聽聽聽聽HttpServletResponse聽response)聽
throws 聽Exception聽{
聽聽聽聽聽聽聽聽
if 聽( ! WebContentGenerator.METHOD_POST.equals(request.getMethod()))聽{
聽聽聽聽聽聽聽聽聽聽聽聽
throw new 聽ServletException( " XmlRpcServiceExporter聽only聽supports聽POST聽requests " );
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽server.execute(request,聽response);
聽聽聽聽聽聽聽聽
return null ;
聽聽聽聽}

聽聽聽聽
/* 聽(non-Javadoc)
聽聽聽聽聽*聽@see聽org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
聽聽聽聽聽
*/
聽聽聽聽
public void 聽afterPropertiesSet()聽 throws 聽Exception聽{
聽聽聽聽聽聽聽聽server聽
= new 聽XmlRpcServletServer();
聽聽聽聽聽聽聽聽server.setHandlerMapping(newXmlRpcHandlerMapping());
聽聽聽聽聽聽聽聽
if 聽(enabledForExtensions != null )聽{
聽聽聽聽聽聽聽聽聽聽聽聽((XmlRpcServerConfigImpl)聽server.getConfig()).setEnabledForExtensions(enabledForExtensions.booleanValue());
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽}

聽聽聽聽
/** 聽Creates聽a聽new聽handler聽mapping.聽The聽default聽implementation聽loads
聽聽聽聽聽*聽a聽property聽file聽from聽the聽resource
聽聽聽聽聽*聽
聽聽聽聽聽
*/
聽聽聽聽
protected 聽XmlRpcHandlerMapping聽newXmlRpcHandlerMapping()聽 throws 聽XmlRpcException聽{
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽SpringHandlerMapping聽mapping聽
= new 聽SpringHandlerMapping(getServiceInterface());
聽聽聽聽聽聽聽聽mapping.addHandler(getServiceName(),聽getServiceInterface());
聽聽聽聽聽聽聽聽mapping.setTagetObject(getProxyForService());
聽聽聽聽聽聽聽聽
return 聽mapping;
聽聽聽聽}
聽聽聽聽
}

spring閰嶇疆鏂囦歡
聽聽聽聽<bean聽id="accountService"聽聽class="com.jdkcn.service.impl.AccountServiceImpl">
聽聽聽聽
</bean>
聽聽聽聽聽聽聽聽
<bean聽name="rpcAccountService"聽class="com.jdkcn.xmlrpc.XmlRpcServiceExporter">
聽聽聽聽聽聽聽聽
<property聽name="service">
聽聽聽聽聽聽聽聽聽聽聽聽
<ref聽bean="accountService"/>
聽聽聽聽聽聽聽聽
</property>
聽聽聽聽聽聽聽聽
<property聽name="serviceName">
聽聽聽聽聽聽聽聽聽聽聽聽
<value>jdkcn.accountService</value>
聽聽聽聽聽聽聽聽
</property>
聽聽聽聽聽聽聽聽
<property聽name="enabledForExtensions">
聽聽聽聽聽聽聽聽聽聽聽聽
<value>true</value>
聽聽聽聽聽聽聽聽
</property>
聽聽聽聽聽聽聽聽
<property聽name="serviceInterface">
聽聽聽聽聽聽聽聽聽聽聽聽
<value>com.jdkcn.service.AccountService</value>
聽聽聽聽聽聽聽聽
</property>
聽聽聽聽
</bean>
鐒跺悗鏄犲皠涓涓湴鍧灝卞彲浠ラ氳繃xmlrpc璁塊棶鏈嶅姟浜?br />
聽聽聽聽<bean聽id="urlMapping"聽class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
聽聽聽聽聽聽聽聽
<property聽name="mappings">
聽聽聽聽聽聽聽聽聽聽聽聽
<props>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
<prop聽key="/account">rpcAccountService</prop>
聽聽聽聽聽聽聽聽聽聽聽聽
</props>
聽聽聽聽聽聽聽聽
</property>
聽聽聽聽
</bean>
web.xml
聽聽聽聽<context-param>
聽聽聽聽聽聽聽聽
<param-name>contextConfigLocation</param-name>
聽聽聽聽聽聽聽聽
<param-value>
聽聽聽聽聽聽聽聽聽聽聽聽classpath:spring/global.xml
聽聽聽聽聽聽聽聽
</param-value>
聽聽聽聽
</context-param>
聽聽聽聽
聽聽聽聽
<listener>
聽聽聽聽聽聽聽聽
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
聽聽聽聽
</listener>

聽聽聽聽聽聽聽聽
<servlet>
聽聽聽聽聽聽聽聽聽聽聽聽
<servlet-name>service</servlet-name>
聽聽聽聽聽聽聽聽聽聽聽聽
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
聽聽聽聽聽聽聽聽
</servlet>

聽聽聽聽聽聽聽聽
<servlet-mapping>
聽聽聽聽聽聽聽聽聽聽聽聽
<servlet-name>service</servlet-name>
聽聽聽聽聽聽聽聽聽聽聽聽
<url-pattern>/service/xmlrpc3/*</url-pattern>
聽聽聽聽聽聽聽聽
</servlet-mapping>
鐒跺悗鎴戜滑鐨剆ervice鍦板潃灝辨槸榪欐牱鐨刪ttp://localhost:8080/service/xmlrpc3/account

甯屾湜瀵瑰ぇ瀹舵湁鐢紝榪欓噷鎻愪緵project涓嬭澆銆傚寘鍚竴涓猚lient紼嬪簭銆俢om.jdkcn.xmlrpc.Client

鐐瑰嚮涓嬭澆瀹屾暣浠g爜

鍒涢犲叡鐢ㄥ崗璁?緗插悕,闈炲晢涓?淇濇寔涓鑷? src=聽聽 闄ょ粡鐗瑰埆娉ㄦ槑澶?鏈枃绔犵増鏉冨綊鑾娉℃場(chǎng)鎵鏈?
緗插悕,闈炲晢涓氱敤閫?淇濇寔涓鑷?聽聽聽somebody(鑾)

鑾 2006-10-22 16:12 鍙戣〃璇勮
]]>
鍏充簬spring鍚姩鐨勪紭鍖栫殑闂http://m.tkk7.com/rory/archive/2006/08/10/speed_up_spring_problem.html鑾鑾Thu, 10 Aug 2006 02:59:00 GMThttp://m.tkk7.com/rory/archive/2006/08/10/speed_up_spring_problem.htmlhttp://m.tkk7.com/rory/comments/62740.htmlhttp://m.tkk7.com/rory/archive/2006/08/10/speed_up_spring_problem.html#Feedback2http://m.tkk7.com/rory/comments/commentRss/62740.htmlhttp://m.tkk7.com/rory/services/trackbacks/62740.htmljspark 鐨勮繖綃囨枃绔犮?a class="postTitle2" id="viewpost1_TitleUrl" href="/jspark/archive/2006/07/29/60712.html">寮鍙戦樁孌礶clipse涓嬮潰鐨剆pring瀹瑰櫒鐨勫惎鍔ㄤ紭鍖?/a> 銆嬭鍒板浣曞姞蹇玸pring鐨勫惎鍔ㄩ熷害銆傞潪甯告劅璋?span style="FONT-WEIGHT: bold">jspark. 涓涓嬫槸寮曠敤鐨勫師鏂囷細(xì)

鏈榪戝湪璐熻矗涓涓ぇ欏圭洰錛岄」鐩粍鎴愬憳鍖呮嫭欏圭洰緇忕悊澶ф10涓漢宸﹀彸銆傞」鐩妧鏈敤struts+spring+hibernate瀹炵幇銆傞」鐩殑瑙勬ā鐩稿鏉ヨ鏄瘮杈冨ぇ鐨勶紝鎬誨叡鏈?0澶фā鍧楋紝姣忎釜澶фā鍧楀張鍒嗕負(fù)鏈夊崄鍑犱釜銆佺敋鑷沖嚑鍗佷釜灝忔ā鍧椼傚紑鍙戝伐鍏風(fēng)敤eclipse錛岀敱浜庡湪寮鍙戦樁孌碉紝欏圭洰寮鍙戞垚鍛橀渶瑕侀綣侀噸鍚湇鍔″櫒銆傚湪鍚姩鏈嶅姟鍣ㄧ殑鏃跺欙紝姣忔鍚姩鏃墮棿鎬繪槸浼?xì)瓒厴q?鍒嗛挓銆傝寰椾互鍓嶅湪鍋氬彟澶栦竴涓」鐩椂錛屽惎鍔ㄦ椂闂翠笉鍒?縐掗挓錛岀浉宸簡(jiǎn)10鍊嶏紝鑰屼笖欏圭洰瑙勬ā鏄樊涓嶅鐨勩?/span>

聽聽聽 浠庡垵姝ュ垎鏋愭潵璇達(dá)紝搴旇鏄痟ibernate瑙i噴hbm.xml鏃惰姳璐規(guī)椂闂達(dá)紝鎴栬呭彲鑳芥槸spring瀹瑰櫒鍚姩騫惰В閲婃墍鏈夌殑bean閰嶇疆鏂囦歡銆傝瘖鏂簡(jiǎn)涓涓嬶紝鍙戠幇1鍒嗛挓娑堣楃殑鏃墮棿涓昏鍒嗗竷鍦╤ibernate瑙i噴hbm.xml鑺辮垂5縐掞紱spring瀹瑰櫒浠庡惎鍔ㄥ埌瑙i噴bean閰嶇疆鏂囦歡绔熺劧鑺變簡(jiǎn)58縐掞紝鐪熸槸澶殻寮犱簡(jiǎn)銆傚綋鏃墮潪甯告鐤憇pring鐨勬晥鐜囬棶棰樸備紒鍥句粠緗戜笂鎼滅儲(chǔ)鐩稿叧璧勬枡錛岀湅鐪嬫湁浠涔堜紭鍖栨帾鏂姐?/span>

聽聽聽 棣栧厛鏄壘鍒頒簡(jiǎn)hibernate鐨勫惎鍔ㄤ紭鍖?http://www.hibernate.org/194.html聽 閲岄潰鐨勪富瑕佹濇兂鏄氳繃灝唜ml搴忓垪鑺卞埌鏈湴鐨勬枃浠墮噷錛屾瘡嬈¤鍙栫殑鏃跺欐牴鎹儏鍐碉紝浠庢湰鍦版枃浠惰鍙栧茍鍙嶅簭鍒楀寲錛岃妭鐪佷簡(jiǎn)hibernate xml鐨勮В鏋愭椂闂淬傛寜鐓ц繖涓柟寮忔祴璇曚簡(jiǎn)涓涓嬶紝鍙戠幇hibernate鐨勫惎鍔ㄦ椂闂翠粠5縐掗檷浣庡埌3縐掞紝浣嗘槸榪欎釜浼樺寲瀵逛簬鏁翠釜鍚姩榪囩▼鏄澂姘磋濺钖殑錛屾鏃犵敤澶勩?/span>

聽聽聽 娌″姙娉曪紝鍙堜粩緇嗘煡鐪嬩簡(jiǎn)spring鐨勮祫鏂欙紝緇堜簬鍙戠幇spring鐨勫鍣ㄦ槸鎻愪緵浜?jiǎn)lazy-load鐨勶紝鍗抽粯璁ょ殑緙虹渷璁劇疆鏄痓ean娌℃湁lazy- load錛岃灞炴у浜巉alse鐘舵侊紝榪欐牱瀵艱嚧spring鍦ㄥ惎鍔ㄨ繃紼嬪鑷村湪鍚姩鏃跺欙紝浼?xì)榛樿鍔犺浇鏁翠釜瀵硅薄瀹炰緥鍥惧Q屼粠鍒濆鍖朅CTION閰嶇疆銆佸埌 service閰嶇疆鍒癲ao閰嶇疆銆佷箖鑷沖埌鏁版嵁搴撹繛鎺ャ佷簨鍔$瓑絳夈傝繖涔堝簽澶х殑瑙勬ā錛岄毦鎬猻pring鐨勫惎鍔ㄦ椂闂磋鑺卞皢榪?鍒嗛挓銆傚皾璇曚簡(jiǎn)涓涓嬶紝鎶奲eans鐨?default-lazy-init鏀逛負(fù)true灝憋紝鍐嶆鍚姩錛岄熷害浠庡師鏉ョ殑55縐掞紝闄嶅埌8縐掗挓錛侊紒Great錛佽櫧鐒舵槸闈炲父灝忎竴涓敼鍔紝浣嗘槸褰卞搷紜疄闈炲父澶с備竴涓」鐩粍10涓漢錛屽亣鑻ユ瘡涓漢涓澶╁鉤鍧囬渶瑕佸湪eclipse涓嬪惎鍔ㄦ祴璇曟湇鍔″櫒50嬈°傞偅涔堜竴澶╅」鐩粍闇瑕侀噸鍚?00嬈★紝姣忔鑺傜渷50縐掔殑璇濓紝灝辨槸 25000縐掞紝灝嗚繎鍑犱釜灝忔椂錛屽樊涓嶅涓涓伐浣滄棩錛屽涔堝彲瑙傜殑鏁板瓧錛?/span>

聽聽 涓嶈繃鍦ㄨ繍琛屾湡闂寸涓嬈$偣欏甸潰鐨勬椂鍊欙紝鐢變簬spring鍋氫簡(jiǎn)lazy-load錛岀幇鍦ㄥ氨闇瑕佸惎鍔ㄤ竴閮ㄥ垎闇瑕佺殑beans錛屾墍浠ョ◢寰參2錛?縐掗挓錛屼絾鏄槑鏄炬瘮絳夊嚑鍗佺瑕佸揩寰堝錛屽煎緱涓閴淬?/span>

聽聽聽 浠ヤ笂鏄拡瀵瑰紑鍙戦樁孌電殑spring瀹瑰櫒鍚姩浼樺寲錛屽湪閮ㄧ講鍒板疄闄呯幆澧冧腑錛屽掓槸娌″繀瑕佽緗負(fù)lazy-load銆傛瘯绔熼儴緗插埌瀹為檯鐜涓笉鏄粡甯哥殑浜嬶紝姣忔鍚姩1鍒嗛挓鍊掍笉鏄ぇ闂銆?

鎴戣繖閲岃鎻愰啋鐨勬槸涓嶆槸璇存湁鐨刡eans閮借兘璁劇疆default-lazy-init鎴愪負(fù)true.瀵逛簬scheduler鐨刡ean涓嶈兘鐢╨azy-init

< beans聽 default-lazy-init ="true" >
聽聽聽聽
聽聽聽聽
< bean聽 class ="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
聽聽聽聽聽聽聽聽
< property聽 name ="triggers" >
聽聽聽聽聽聽聽聽聽聽聽聽
< list >
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="buildHtmlTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="askTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="mailSenderTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="topicDetailBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="forumBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="topicBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽
</ list >
聽聽聽聽聽聽聽聽
</ property >
聽聽聽聽
</ bean >
</ beans >




榪欐牱鐨勮瘽銆傛墍鏈夌殑scheduler灝遍兘涓嶇鐢ㄤ簡(jiǎn)銆傛墍浠ヨ澶у瑕佹敞鎰忋?br />

< beans >
聽聽聽聽
聽聽聽聽
< bean聽 class ="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
聽聽聽聽聽聽聽聽
< property聽 name ="triggers" >
聽聽聽聽聽聽聽聽聽聽聽聽
< list >
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="buildHtmlTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="askTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="mailSenderTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="topicDetailBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="forumBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
< ref聽 bean ="topicBuildTrigger" />
聽聽聽聽聽聽聽聽聽聽聽聽
</ list >
聽聽聽聽聽聽聽聽
</ property >
聽聽聽聽
</ bean >
</ beans >




鑾 2006-08-10 10:59 鍙戣〃璇勮
]]>
鍏充簬Freemarker鐢熸垚闈?rùn)鎬佹枃浠剁殑闂http://m.tkk7.com/rory/archive/2006/06/21/54134.html鑾鑾Wed, 21 Jun 2006 02:46:00 GMThttp://m.tkk7.com/rory/archive/2006/06/21/54134.htmlhttp://m.tkk7.com/rory/comments/54134.htmlhttp://m.tkk7.com/rory/archive/2006/06/21/54134.html#Feedback0http://m.tkk7.com/rory/comments/commentRss/54134.htmlhttp://m.tkk7.com/rory/services/trackbacks/54134.html浣跨敤FreeMarker鐢熸垚Html闈?rùn)鎬佹枃浠?瀹炰緥)銆?br />聽聽聽聽聽 鍦ㄦ垜浠殑欏圭洰涓篃鐢ㄥ埌浜?jiǎn)Freemarker鐢熸垚闈?rùn)鎬佹枃浠躲備笉榪囪繖閲屾垜瑕佽鐨勬槸緙栫爜鐨勯棶棰樸傛垜浠殑欏圭洰浣跨敤鐨勯兘鏄疷TF-8緙栫爜錛屾垜鐩存帴浣跨敤 椋炰簯灝忎緺 鎻愪緵鐨勬柟娉曠敓鎴愮殑鏂囦歡鍦║TF-8緙栫爜涓嬪療鐪嬫槸涔辯爜錛岃孏BK姝e父(鍚庢潵鍙戠幇鍥犱負(fù)鎴戠敤鐨勪腑鏂囨搷浣滅郴緇熸墍浠ョ敤GBK鏌ョ湅姝e父)銆?br />聽聽聽聽聽 褰撶劧鎴戞妸Freemarker鐨勯厤緗兘鏀規(guī)垚浜?jiǎn)UTF-8錛屾垜鐨勬ā鐗堟枃浠朵篃鏄疷TF-8緙栫爜鐨勩備笅闈㈡槸鍘熸潵鐨勪唬鐮?br />
聽聽聽聽publicvoid聽setTemplatePath(Resource聽templatePath)聽{
聽聽聽聽聽聽聽聽
this.templatePath聽=聽templatePath;
聽聽聽聽聽聽聽聽
//璁劇疆freemarker鐨勫弬鏁?/span>
聽聽聽聽聽聽聽聽freemarkerCfg聽=new聽Configuration();
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDirectoryForTemplateLoading(
this.templatePath.getFile());
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setObjectWrapper(
new聽DefaultObjectWrapper());
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDefaultEncoding(
"UTF-8");
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽ex)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
thrownew聽SystemException("No聽Directory聽found,please聽check聽you聽config.");
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽/**
聽聽聽聽聽*聽鐢熸垚闈?rùn)鎬佹枃浠?br />聽聽聽聽聽*聽
@param聽templateFileName聽妯$増鍚嶇Оeg:(biz/order.ftl)
聽聽聽聽聽*聽
@param聽propMap聽鐢ㄤ簬澶勭悊妯℃澘鐨勫睘鎬bject鏄犲皠聽
聽聽聽聽聽*聽
@param聽htmlFilePath聽瑕佺敓鎴愮殑闈?rùn)鎬佹枃浠剁殑璺緞,鐩稿璁劇疆涓殑鏍硅礬寰?渚嬪聽"/biz/2006/5/"聽
聽聽聽聽聽*聽
@param聽htmlFileName聽瑕佺敓鎴愮殑鏂囦歡鍚?渚嬪聽"123.htm"聽
聽聽聽聽聽*聽
@return
聽聽聽聽聽
*/
聽聽聽聽
privateboolean聽buildHtml(String聽templateFileName,Map聽propMap,聽String聽htmlFilePath,String聽htmlFileName){
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽Template聽template聽
=聽freemarkerCfg.getTemplate(templateFileName);
聽聽聽聽聽聽聽聽聽聽聽聽template.setEncoding(
"UTF-8");
聽聽聽聽聽聽聽聽聽聽聽聽
//鍒涘緩鐢熸垚鏂囦歡鐩綍
聽聽聽聽聽聽聽聽聽聽聽聽creatDirs(buildPath.getFilename(),htmlFilePath);
聽聽聽聽聽聽聽聽聽聽聽聽File聽htmlFile聽
=new聽File(buildPath聽+聽htmlFilePath聽+聽htmlFileName);
聽聽聽聽聽聽聽聽聽聽聽聽Writer聽out聽
=new聽BufferedWriter(new聽OutputStreamWriter(new聽FileOutputStream(htmlFile)));
聽聽聽聽聽聽聽聽聽聽聽聽template.process(propMap,out);
聽聽聽聽聽聽聽聽聽聽聽聽out.flush();
聽聽聽聽聽聽聽聽聽聽聽聽
returntrue;
聽聽聽聽聽聽聽聽}聽
catch聽(TemplateException聽ex){
聽聽聽聽聽聽聽聽聽聽聽聽log.error(
"Build聽Error"+templateFileName,ex);
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽log.error(
"Build聽Error"+templateFileName,e);
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽}
涓嬮潰鏄慨鏀逛箣鍚庣殑浠g爜
聽聽聽聽/**
聽聽聽聽聽*聽鐢熸垚闈?rùn)鎬佹枃浠?br />聽聽聽聽聽*聽
@param聽templateFileName聽妯$増鍚嶇Оeg:(biz/order.ftl)
聽聽聽聽聽*聽
@param聽propMap聽鐢ㄤ簬澶勭悊妯℃澘鐨勫睘鎬bject鏄犲皠聽
聽聽聽聽聽*聽
@param聽htmlFilePath聽瑕佺敓鎴愮殑闈?rùn)鎬佹枃浠剁殑璺緞,鐩稿璁劇疆涓殑鏍硅礬寰?渚嬪聽"/biz/2006/5/"聽
聽聽聽聽聽*聽
@param聽htmlFileName聽瑕佺敓鎴愮殑鏂囦歡鍚?渚嬪聽"123.htm"聽
聽聽聽聽聽*聽
@return
聽聽聽聽聽
*/
聽聽聽聽
privateboolean聽buildHtml(String聽templateFileName,Map聽propMap,聽String聽htmlFilePath,String聽htmlFileName){
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽Template聽template聽
=聽freemarkerCfg.getTemplate(templateFileName);
聽聽聽聽聽聽聽聽聽聽聽聽template.setEncoding(
"UTF-8");
聽聽聽聽聽聽聽聽聽聽聽聽
//鍒涘緩鐢熸垚鏂囦歡鐩綍
聽聽聽聽聽聽聽聽聽聽聽聽creatDirs(buildPath.getFilename(),htmlFilePath);
聽聽聽聽聽聽聽聽聽聽聽聽File聽htmlFile聽
=new聽File(buildPath聽+聽htmlFilePath聽+聽htmlFileName);
聽聽聽聽聽聽聽聽聽聽聽聽Writer聽out聽
=new聽BufferedWriter(new聽OutputStreamWriter(new聽FileOutputStream(htmlFile),"UTF-8"));
聽聽聽聽聽聽聽聽聽聽聽聽template.process(propMap,out);
聽聽聽聽聽聽聽聽聽聽聽聽out.flush();
聽聽聽聽聽聽聽聽聽聽聽聽
returntrue;
聽聽聽聽聽聽聽聽}聽
catch聽(TemplateException聽ex){
聽聽聽聽聽聽聽聽聽聽聽聽log.error(
"Build聽Error"+templateFileName,ex);
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽log.error(
"Build聽Error"+templateFileName,e);
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽}
鍘熷洜灝卞湪浜嶰utputStreamWriter鐨勪笉鍚屾瀯閫犳柟娉?br />
OutputStreamWriter(OutputStream聽out)
聽聽聽聽聽聽聽聽聽聽鍒涘緩浣跨敤榛樿瀛楃緙栫爜鐨?OutputStreamWriter銆?br />
OutputStreamWriter(OutputStream聽out, String聽charsetName)
聽聽聽聽聽聽聽聽聽聽鍒涘緩浣跨敤鎸囧畾瀛楃闆嗙殑 OutputStreamWriter銆?br />
榪欎釜鏄腑鏂嘕DK鐨勬枃妗h鏄庯紝鍒氬紑濮嬫垜浣跨敤榛樿鐨勬瀯閫犲嚱鏁幫紝鎵浠ヤ嬌鐢ㄤ簡(jiǎn)緋葷粺榛樿鐨勭紪鐮侊紝GBK錛屾墍浠ュ湪鐢熸垚闈?rùn)鎬佹枃浠剁殑鏃跺欐妸UTF-8鍐呭鐢℅BK緙栫爜鍐欏叆浜?jiǎn)锛屾墍浠ュ湪UTF-8涓嬫祻瑙堝氨鏈夐棶棰樸?br />
榪樻湁鍏充簬淇敼妯$増鏂囦歡鍚屾牱涔熻娉ㄦ剰榪欎釜闂銆?br />
聽聽聽聽public聽String聽loadTemplate(String聽templateName)聽{
聽聽聽聽聽聽聽聽StringBuffer聽sb聽
=new聽StringBuffer();
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽File聽file聽
=new聽File(templatePath+"/"+templateName);
聽聽聽聽聽聽聽聽聽聽聽聽BufferedReader聽reader聽
=new聽BufferedReader(new聽I(yíng)nputStreamReader(new聽FileInputStream(file),"UTF-8"));
聽聽聽聽聽聽聽聽聽聽聽聽String聽line聽
=聽reader.readLine();
聽聽聽聽聽聽聽聽聽聽聽聽
while(line聽!=null)聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sb.append(line);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sb.append(
"\r\n");
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽line聽
=聽reader.readLine();
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽reader.close();
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
thrownew聽SystemException("Loading聽template聽Error:",e);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return聽sb.toString();
聽聽聽聽}
聽聽聽聽publicvoid聽saveTemplate(String聽templateName,聽String聽templateContent)聽{
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽File聽file聽
=new聽File(templatePath聽+"/"+聽templateName);
聽聽聽聽聽聽聽聽聽聽聽聽Writer聽out聽
=new聽BufferedWriter(new聽OutputStreamWriter(new聽FileOutputStream(file),"UTF-8"));
聽聽聽聽聽聽聽聽聽聽聽聽out.write(templateContent);
聽聽聽聽聽聽聽聽聽聽聽聽out.flush();
聽聽聽聽聽聽聽聽聽聽聽聽
//鎵斿嚭templatesave浜嬩歡
聽聽聽聽聽聽聽聽聽聽聽聽TemplateSaveEvent聽evt聽=new聽TemplateSaveEvent();
聽聽聽聽聽聽聽聽聽聽聽聽evt.setTemplateName(templateName);
聽聽聽聽聽聽聽聽聽聽聽聽dispatchTemplateEvent(evt);
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
thrownew聽SystemException("Write聽template聽Error",e);
聽聽聽聽聽聽聽聽}
聽聽聽聽}



鑾 2006-06-21 10:46 鍙戣〃璇勮
]]>
spring鍏充簬搴曞眰璧勬簮鐨勬娊璞℃槸濡傛鏂逛究http://m.tkk7.com/rory/archive/2006/06/11/52065.html鑾鑾Sun, 11 Jun 2006 15:01:00 GMThttp://m.tkk7.com/rory/archive/2006/06/11/52065.htmlhttp://m.tkk7.com/rory/comments/52065.htmlhttp://m.tkk7.com/rory/archive/2006/06/11/52065.html#Feedback2http://m.tkk7.com/rory/comments/commentRss/52065.htmlhttp://m.tkk7.com/rory/services/trackbacks/52065.html聽聽聽聽 鏈榪戠湅銆奝rofessional Java Development with the Spring Framework銆嬫椂鐪嬪埌浜?jiǎn)spring瀵瑰簳灞傝祫婧愮殑鎶借薄錛屾墠鎵懼埌浜?jiǎn)瀹尵煄瑙e喯x柟妗堛?br />聽聽聽聽 鍘熸潵鐨勪唬鐮侊細(xì)
聽聽聽聽private聽String聽templatePath;
聽聽聽聽
publicvoid聽setTemplatePath(String聽templatePath)聽{
聽聽聽聽聽聽聽聽
this.templatePath聽=聽templatePath;
聽聽聽聽}
聽聽聽聽
publicvoid聽initListener()聽{
聽聽聽聽聽聽聽聽TemplateEventListener聽templateListener聽
=new聽TemplateEventListener(){
聽聽聽聽聽聽聽聽聽聽聽聽
publicvoid聽handleTemplateEvent(TemplateEventSupport聽evt)聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
//聽娣誨姞浜嬩歡鍒伴槦鍒椾腑
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽queue.offer(evt);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(log.isDebugEnabled()){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽log.debug(
"Add聽Template聽about:"+聽evt.getTemplateName());
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽};
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//娉ㄥ唽妯$増鐩戝惉浜嬩歡
聽聽聽聽聽聽聽聽templateManager.addEventListener(Constants.TEMPLATE_SAVE_EVENT,聽templateListener,false);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//璁劇疆freemarker鐨勫弬鏁?/span>
聽聽聽聽聽聽聽聽freemarkerCfg聽=new聽Configuration();
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDirectoryForTemplateLoading(
new聽File(templatePath));
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setObjectWrapper(
new聽DefaultObjectWrapper());
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDefaultEncoding(
"UTF-8");
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽ex)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
thrownew聽SystemException("No聽Directory聽found,please聽check聽you聽config.");
聽聽聽聽聽聽聽聽}
聽聽聽聽}
閰嶇疆鏂囦歡

聽聽聽聽
<bean聽id="buildHtmlService"聽class="cn.jdk.leaf.service.impl.BuildHtmlServiceImpl"聽init-method="initListener">
聽聽聽聽聽聽聽聽
<property聽name="templatePath"><value>${templatePath}</value></property>
聽聽聽聽
</bean>
templatePath.path=D:/template
浣跨敤spring瀵瑰簳灞傝祫婧愮殑鎶借薄鍙鎶妕emplatePath鏀規(guī)垚Resource灝卞彲浠ヤ簡(jiǎn)
聽聽聽聽private聽Resource聽templatePath;
聽聽聽聽
publicvoid聽setTemplatePath(Resource聽templatePath)聽{
聽聽聽聽聽聽聽聽
this.templatePath聽=聽templatePath;
聽聽聽聽}
聽聽聽聽
publicvoid聽initListener()聽{
聽聽聽聽聽聽聽聽聽聽聽聽TemplateEventListener聽templateListener聽
=new聽TemplateEventListener(){
聽聽聽聽聽聽聽聽聽聽聽聽
publicvoid聽handleTemplateEvent(TemplateEventSupport聽evt)聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
//聽娣誨姞浜嬩歡鍒伴槦鍒椾腑
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽queue.offer(evt);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(log.isDebugEnabled()){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽log.debug(
"Add聽Template聽about:"+聽evt.getTemplateName());
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽};聽聽聽聽
聽聽聽聽聽聽聽聽
//娉ㄥ唽妯$増鐩戝惉浜嬩歡
聽聽聽聽聽聽聽聽templateManager.addEventListener(Constants.TEMPLATE_SAVE_EVENT,聽templateListener,false);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//璁劇疆freemarker鐨勫弬鏁?/span>
聽聽聽聽聽聽聽聽freemarkerCfg聽=new聽Configuration();
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDirectoryForTemplateLoading(templatePath.getFile());
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setObjectWrapper(
new聽DefaultObjectWrapper());
聽聽聽聽聽聽聽聽聽聽聽聽freemarkerCfg.setDefaultEncoding(
"UTF-8");
聽聽聽聽聽聽聽聽}聽
catch聽(IOException聽ex)聽{
聽聽聽聽聽聽聽聽聽聽聽聽
thrownew聽SystemException("No聽Directory聽found,please聽check聽you聽config.");
聽聽聽聽聽聽聽聽}
聽聽聽聽}
bean鐨勯厤緗笉鍙橈紝鍙淇敼properties鏂囦歡灝卞彲浠ヤ簡(jiǎn)銆?br />
聽聽聽聽<bean聽id="buildHtmlService"class="cn.jdk.leaf.service.impl.BuildHtmlServiceImpl"聽init-method="initListener">
聽聽聽聽聽聽聽聽
<property聽name="templatePath"><value>${templatePath}</value></property>
聽聽聽聽
</bean>
鎶妏roperties鏂囦歡淇敼鎴?br />
templatePath.path=template
鍦╳ebcontext鐩綍涓嬮潰寤虹珛涓涓猼emplate鐩綍灝卞彲浠ヤ簡(jiǎn)銆傚湪閮ㄧ講鍒版湇鍔″櫒鐨勬椂鍊欓渶瑕侀儴緗插埌涓涓壒瀹氱殑鐩綍鍙淇敼榪欎釜閰嶇疆鏂囦歡涓?br />
templatePath.path=file:/D:/template
榪欐牱灝卞彲浠ヤ簡(jiǎn)銆?br />
鍒涢犲叡鐢ㄥ崗璁?緗插悕,闈炲晢涓?淇濇寔涓鑷? src=聽聽闄ょ粡鐗瑰埆娉ㄦ槑澶?鏈枃绔犵増鏉冨綊鑾娉℃場(chǎng)鎵鏈?
緗插悕,闈炲晢涓氱敤閫?淇濇寔涓鑷?聽聽聽somebody(鑾)聽聽聽


鑾 2006-06-11 23:01 鍙戣〃璇勮
]]>
鍏充簬Hibernate鐨凞etachedCriteria鏌ヨ鐨刟ddOrder闂鐨勮В鍐沖姙娉?/title><link>http://m.tkk7.com/rory/archive/2006/05/29/48850.html</link><dc:creator>鑾</dc:creator><author>鑾</author><pubDate>Mon, 29 May 2006 15:29:00 GMT</pubDate><guid>http://m.tkk7.com/rory/archive/2006/05/29/48850.html</guid><wfw:comment>http://m.tkk7.com/rory/comments/48850.html</wfw:comment><comments>http://m.tkk7.com/rory/archive/2006/05/29/48850.html#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://m.tkk7.com/rory/comments/commentRss/48850.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/rory/services/trackbacks/48850.html</trackback:ping><description><![CDATA[涓婄瘒鏂囩珷:銆?a class="singleposttitle" id="viewpost1_TitleUrl" href="/rory/archive/2006/05/21/47339.html"><font color="#223355"><strong>浠婂ぉ鍙戠幇涓涓猦ibernate鐨刡ug,鎴栬呰涓涓簲璇ユ敞鎰忕殑鍦版柟姣旇緝鍚堥?/strong></font></a> 銆嬮噷闈㈡垜鎻愬埌浜?jiǎn)Hibernate鏌ヨ闇瑕佹敞鎰忕殑涓涓棶棰樸備粖澶╁彂鐜頒簡(jiǎn)涓涓渶濂界殑瑙e喅鍔炴硶銆傚鏋滃ぇ瀹剁幇鍦ㄧ敤Hibernate錛岀浉淇″ぇ瀹墮兘鍥炵敤鍒癉etachedCriteria.鍏充簬DetachedCriteria鏌ヨ璇鋒煡鐪?a >http://dev.yesky.com/241/2033241.shtml</a>銆?br />聽聽聽聽聽 DetachedCriteria緇欐垜浠殑Hibernate鏌ヨ甯︽潵浜?jiǎn)寰堝鏂逛究锛屼絾鏄鏋滀綘甯︿笂鎺掑簭淇℃伅灏变細(xì)鍑虹幇鎴戠殑涓婁竴綃囨枃绔犻噷闈㈣鐨勯偅縐嶉敊璇紝浠婂ぉ鍙戠幇涓涓緢濂界殑瑙e喅鏂規(guī)硶錛屽叾瀹炰篃寰堢畝鍗曘傚氨鏄厛鎶婁紶鍏ョ殑甯rder淇℃伅鐨凞etachedCriteria鍘繪帀order淇℃伅鏌ヨ鏁版嵁鎬繪潯鏁幫紝鐒跺悗鍐嶆妸Order鍔犲洖鏉ユ煡璇㈡弧瓚蟲潯浠剁殑瀵硅薄銆傞氳繃鏌ョ湅Hibernate鐨勬簮浠g爜鍙戠幇Criteria鐨勫疄鐜癈riteriaImpl鍙戠幇鍏跺疄addOrder鏄粰private List orderEntries = new ArrayList();榪欎釜List鍔犲箋傝繖涓狶ist閲岄潰鏀劇殑鏄疧rderEntry瀵硅薄銆傝繖涓狾rderEntry閲岄潰鏀句簡(jiǎn)涓涓猚riteria 鍜?order.<br /><br />聽聽聽聽 <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽PaginationSupport聽findPageByCriteria(</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽DetachedCriteria聽detachedCriteria,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽pageSize,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽startIndex)聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽(PaginationSupport)聽getHibernateTemplate().execute(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽HibernateCallback()聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽Object聽doInHibernate(Session聽session)聽</span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000">聽HibernateException聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Criteria聽criteria聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽detachedCriteria.getExecutableCriteria(session);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽CriteriaImpl聽impl聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(CriteriaImpl)聽criteria;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽orderEntrys聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽ArrayList();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000">{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Field聽field聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽CriteriaImpl.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">.getDeclaredField(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">orderEntries</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Get聽orders</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽orderEntrys聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(List)聽field.get(impl);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Remove聽orders</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽field.set(criteria,</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽ArrayList());<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(Exception聽ex){<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ex.printStackTrace();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">TODO聽xxxx</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽totalCount聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽((Integer)聽criteria.setProjection(Projections.rowCount())<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽.uniqueResult()).intValue();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽criteria.setProjection(</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000">{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Field聽field聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽CriteriaImpl.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">.getDeclaredField(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">orderEntries</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Add聽orders聽return</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;聽i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">orderEntrys.size();聽i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">){<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽innerOrderEntries聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(List)聽field.get(criteria);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽innerOrderEntries.add(orderEntrys.get(i));<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(Exception聽ex){<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ex.printStackTrace();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">TODO聽cccc</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽items聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽criteria.setFirstResult(startIndex).setMaxResults(pageSize).list();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽PaginationSupport聽ps聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽PaginationSupport(items,聽totalCount,聽pageSize,<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽startIndex);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽ps;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽},聽</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">);<br />聽聽聽聽}</span></div>甯屾湜澶у澶氬浜ゆ祦<img src ="http://m.tkk7.com/rory/aggbug/48850.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/rory/" target="_blank">鑾</a> 2006-05-29 23:29 <a href="http://m.tkk7.com/rory/archive/2006/05/29/48850.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍏充簬Hibernate3鐨凬ativeSQL鏌ヨ鏄姝ょ畝鍗?/title><link>http://m.tkk7.com/rory/archive/2006/05/26/48274.html</link><dc:creator>鑾</dc:creator><author>鑾</author><pubDate>Fri, 26 May 2006 02:33:00 GMT</pubDate><guid>http://m.tkk7.com/rory/archive/2006/05/26/48274.html</guid><wfw:comment>http://m.tkk7.com/rory/comments/48274.html</wfw:comment><comments>http://m.tkk7.com/rory/archive/2006/05/26/48274.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/rory/comments/commentRss/48274.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/rory/services/trackbacks/48274.html</trackback:ping><description><![CDATA[鐜板湪鐨勭郴緇熶腑铏界劧浣跨敤浜?jiǎn)銆侶ibernate浣嗘槸娌℃湁浣跨敤Hibernate鐨勫叧鑱斿叧緋繪潵榪涜鏁版嵁搴撴搷浣溿傛墍鏈夌殑綆$悊鎿嶄綔閮芥槸鍗曠嫭瀹炵幇鐨勩傛墍浠ヤ篃涓嶈兘鐢–riteria.add()榪欑鏂瑰紡鍘繪煡璇㈠叧鑱旂殑涓鏂廣傛墍浠ュ彧鑳界敤Native SQL鍘繪煡璇㈢粨鏋滆繑鍥炲璞′簡(jiǎn)銆傛寜鐓ibernate3鐨剅eference閲岄潰璇寸殑<br /><div id="1666666" class="sect1" lang="zh-cn"><div id="6111616" class="titlepage"><div><div><h2 class="title" style="CLEAR: both"><font color="#006400">16.1.聽浣跨敤<tt class="literal">SQLQuery</tt></font></h2></div></div><div><font color="#006400"></font></div></div><p><font color="#006400">瀵瑰師鐢烻QL鏌ヨ鎵ц鐨勬帶鍒舵槸閫氳繃<tt class="literal">SQLQuery</tt>鎺ュ彛榪涜鐨勶紝閫氳繃鎵ц<tt class="literal">Session.createSQLQuery()</tt>鑾峰彇榪欎釜鎺ュ彛銆傛渶綆鍗曠殑鎯呭喌涓嬶紝鎴戜滑鍙互閲囩敤浠ヤ笅褰㈠紡錛?/font></p><pre class="programlisting"><font color="#006400">List cats = sess.createSQLQuery("select * from cats") .addEntity(Cat.class) .list();</font></pre><p><font color="#006400">榪欎釜鏌ヨ鎸囧畾浜?</font></p><div id="1611161" class="itemizedlist"><ul type="disc"><li><p><font color="#006400">SQL鏌ヨ瀛楃涓?/font></p></li><li><p><font color="#006400">鏌ヨ榪斿洖鐨勫疄浣?/font></p></li></ul></div><p><font color="#006400">榪欓噷錛岀粨鏋滈泦瀛楁鍚嶈鍋囪涓轟笌鏄犲皠鏂囦歡涓寚鏄庣殑瀛楁鍚嶇浉鍚屻傚浜庤繛鎺ヤ簡(jiǎn)澶氫釜琛ㄧ殑鏌ヨ錛岃繖灝卞彲鑳介犳垚闂錛屽洜涓哄彲鑳藉湪澶氫釜琛ㄤ腑鍑虹幇鍚屾牱鍚嶅瓧鐨勫瓧孌點(diǎn)備笅闈㈢殑鏂規(guī)硶灝卞彲浠ラ伩鍏嶅瓧孌靛悕閲嶅鐨勯棶棰?</font></p><pre class="programlisting"><font color="#006400">List cats = sess.createSQLQuery("select {cat.*} from cats cat") .addEntity("cat", Cat.class) .list();</font></pre><p><font color="#006400">榪欎釜鏌ヨ鎸囧畾浜? </font></p><div id="6616161" class="itemizedlist"><ul type="disc"><li><p><font color="#006400">SQL鏌ヨ璇彞錛屽畠甯︿竴涓崰浣嶇錛屽彲浠ヨHibernate浣跨敤瀛楁鐨勫埆鍚? </font></p></li><li><p><font color="#006400">鏌ヨ榪斿洖鐨勫疄浣擄紝鍜屽畠鐨凷QL琛ㄧ殑鍒悕. </font></p></li></ul></div><p><font color="#006400"><tt class="literal">addEntity()</tt>鏂規(guī)硶灝哠QL琛ㄧ殑鍒悕鍜屽疄浣撶被鑱旂郴璧鋒潵錛屽茍涓旂‘瀹氭煡璇㈢粨鏋滈泦鐨勫艦鎬併?</font></p><p><font color="#006400"><tt class="literal">addJoin()</tt>鏂規(guī)硶鍙互琚敤浜庤澆鍏ュ叾浠栫殑瀹炰綋鍜岄泦鍚堢殑鍏寵仈. </font></p><pre class="programlisting"><font color="#006400">List cats = sess.createSQLQuery( "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id" ) .addEntity("cat", Cat.class) .addJoin("kitten", "cat.kittens") .list();</font></pre><p><font color="#006400">鍘熺敓鐨凷QL鏌ヨ鍙兘榪斿洖涓涓畝鍗曠殑鏍囬噺鍊兼垨鑰呬竴涓爣閲忓拰瀹炰綋鐨勭粨鍚堜綋銆?</font></p><pre class="programlisting"><font color="#006400">Double max = (Double) sess.createSQLQuery("select max(cat.weight) as maxWeight from cats cat") .addScalar("maxWeight", Hibernate.DOUBLE); .uniqueResult();</font></pre><p><font color="#006400">闄ゆ涔嬪錛屼綘榪樺彲浠ュ湪浣犵殑hbm鏂囦歡涓弿榪扮粨鏋滈泦鏄犲皠淇℃伅錛屽湪鏌ヨ涓嬌鐢ㄣ?/font></p><pre class="programlisting"><font color="#006400">List cats = sess.createSQLQuery( "select {cat.*}, {kitten.*} from cats cat, cats kitten where kitten.mother = cat.id" ) .setResultSetMapping("catAndKitten") .list();<br /></font></pre></div><br />鍚庢潵鎴戜嬌鐢ㄤ簡(jiǎn)鍛藉悕SQL鏌ヨ鏂瑰紡銆?br /><div id="6661611" class="titlepage"><div><div><h2 class="title" style="CLEAR: both"><font color="#006400">16.3.聽鍛藉悕SQL鏌ヨ</font></h2></div></div><div><font color="#006400"></font></div></div><p><font color="#006400">鍙互鍦ㄦ槧灝勬枃妗d腑瀹氫箟鏌ヨ鐨勫悕瀛?鐒跺悗灝卞彲浠ヨ薄璋冪敤涓涓懡鍚嶇殑HQL鏌ヨ涓鏍風(fēng)洿鎺ヨ皟鐢ㄥ懡鍚峉QL鏌ヨ.鍦ㄨ繖縐嶆儏鍐典笅,鎴戜滑<span id="1166611" class="emphasis"><em>涓?/em></span> 闇瑕佽皟鐢?tt class="literal">addEntity()</tt>鏂規(guī)硶. </font></p><pre class="programlisting"><font color="#006400"><sql-query name="persons"> <return alias="person" class="eg.Person"/> SELECT person.NAME AS {person.name}, person.AGE AS {person.age}, person.SEX AS {person.sex} FROM PERSON person WHERE person.NAME LIKE :namePattern </sql-query></font></pre><pre class="programlisting"><font color="#006400">List people = sess.getNamedQuery("persons") .setString("namePattern", namePattern) .setMaxResults(50) .list();</font><br /><br />鎴戣寰楄繖縐嶅彂寮忔瘮杈冨ソ銆傝繖鏍峰啓鍑烘潵鐨剆ql鍙互寰堟暣榻愩傛垜浠殑鏁版嵁搴撲嬌鐢ㄧ殑鏄痮racle錛屼笉榪囨寜鐓ц繖涓婇潰鐨勫啓娉曞彂鐜皊ql璇彞鏈夐敊璇?br />鍚庢潵鎷垮埌鎺у埗鍙版墽琛屼篃鎶遍敊銆傚洜涓哄師鏉ラ兘鐢╯qlserver錛岃宻qlserver閮芥槸鍙互鐨勩傚悗鏉ュ彂鐜版槸琛ㄤ笉鑳芥湁鍒悕鏀規(guī)垚榪欐牱灝卞ソ浜?jiǎn)銆?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">聽T_PAY.sys_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.sys_flag聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysFlag},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.sys_domain聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysDomain},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.sys_owner聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysOwner},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.sys_create_date聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysCreateDate},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.sys_update_date聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.sysUpdateDate},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.pay_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.pay_name聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payName},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.pay_type_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payTypeId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.pay_date聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payDate},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.money_type_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.moneyTypeId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.amount聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.amount},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.payer_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payerId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.payer_name聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payerName},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.accept_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.acceptId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.accept_name聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.acceptName},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.pay_state_id聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.payStateId},<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽T_PAY.remark聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽{pay.remark}<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">聽聽聽T_PAY<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">JOIN</span><span style="COLOR: #000000">聽聽聽T_BIZ_PAY<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">ON</span><span style="COLOR: #000000">聽聽聽聽聽聽聽T_PAY.pay_id聽</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">聽T_BIZ_PAY.pay_id<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">聽聽T_BIZ_PAY.biz_id聽</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">聽:bizId</span></div></pre>聽 <strong>榪欓噷瑕佺壒鍒殑鎻愰啋涓涓嬪ぇ瀹跺崈涓囦笉瑕佹妸涓婚敭蹇樹簡(jiǎn)銆傚垰寮濮嬫垜灝卞繕浜?jiǎn)涓婚敭锛屽悗鏉ヨ皟璇曚簡(jiǎn)鍗婂ぉ鎵嶆墤謬哄師鍥犳潵銆?br /></strong><br />榪欐牱鍦╯ping閲岄潰鐢ㄥ洖璋冩煡璇竴涓嬪氨ok浜?jiǎn)銆傜湡鐨勫緢鏂逛究.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽List聽getPaysByBizId(</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽String聽bizId)聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽(List)getHibernateTemplate().execute(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽HibernateCallback(){<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽Object聽doInHibernate(Session聽session)</span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000">聽HibernateException{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Query聽query聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽session.getNamedQuery(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">find.pays.by.bizid</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽query.setParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">bizId</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,bizId);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽query.list();<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽},</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">);<br />聽聽聽聽}</span></div><img src ="http://m.tkk7.com/rory/aggbug/48274.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/rory/" target="_blank">鑾</a> 2006-05-26 10:33 <a href="http://m.tkk7.com/rory/archive/2006/05/26/48274.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浠婂ぉ鍙戠幇涓涓猦ibernate鐨刡ug,鎴栬呰涓涓簲璇ユ敞鎰忕殑鍦版柟姣旇緝鍚堥?/title><link>http://m.tkk7.com/rory/archive/2006/05/21/47339.html</link><dc:creator>鑾</dc:creator><author>鑾</author><pubDate>Sun, 21 May 2006 14:49:00 GMT</pubDate><guid>http://m.tkk7.com/rory/archive/2006/05/21/47339.html</guid><wfw:comment>http://m.tkk7.com/rory/comments/47339.html</wfw:comment><comments>http://m.tkk7.com/rory/archive/2006/05/21/47339.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://m.tkk7.com/rory/comments/commentRss/47339.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/rory/services/trackbacks/47339.html</trackback:ping><description><![CDATA[浠婂ぉ鎶妋yblog鐢╯ql server閮ㄧ講浜?jiǎn)涓涓嬶紝鍙槸鍙戠幇鍒嗛〉鏌ヨ鐨勬椂鍊欏嚭鐜伴敊璇紝鐪嬫帶鍒跺彴鎶ラ敊璇磋鍙ユ湁閿?鐢辨潵鍙戠幇鍒嗛〉鐨勬椂鍊欏厛鏌ヨ鎬昏褰曟暟鐩殑閭f潯璇彞鍑洪敊浜?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">聽</span><span style="COLOR: #ff00ff">count</span><span style="COLOR: #000000">(</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">)聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽y0_聽</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">聽myblog_Blog聽this_聽</span><span style="COLOR: #0000ff">inner</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">join</span><span style="COLOR: #000000">聽myblog_Blog_Category聽categories3_聽</span><span style="COLOR: #0000ff">on</span><span style="COLOR: #000000">聽this_.id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">categories3_.blogId聽</span><span style="COLOR: #0000ff">inner</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">join</span><span style="COLOR: #000000">聽myblog_Category聽category1_聽</span><span style="COLOR: #0000ff">on</span><span style="COLOR: #000000">聽categories3_.categoryId</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">category1_.id聽</span><span style="COLOR: #0000ff">where</span><span style="COLOR: #000000">聽category1_.id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">?聽</span><span style="COLOR: #0000ff">order</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">by</span><span style="COLOR: #000000">聽this_.postTime聽</span><span style="COLOR: #0000ff">desc</span></div>聽聽聽聽聽 鍘熸潵寮鍙戠殑鏃跺欐垜鏄敤鐨刴ysql錛屾病鏈変換浣曢棶棰樸傚師鍥犲氨鍦ㄦ渶鍚庨潰鐨刼rder by 璇彞錛宻ql server 鍦╯elect count(*)閲岄潰涓嶈兘鐢?order by銆傜劧鍚庤窡韙唬鐮佸彂鐜?<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽PaginationSupport聽getBlogsByCategoryByPage(</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽String聽categoryId,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽startIndex,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽pageSize)聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽(PaginationSupport)聽getHibernateTemplate().execute(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽HibernateCallback()聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽Object聽doInHibernate(Session聽session)聽</span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000">聽HibernateException聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Criteria聽criteria聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽session.createCriteria(Blog.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Criteria聽cateCriteria聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽criteria.createCriteria(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">categories</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cateCriteria.add(Expression.eq(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,categoryId));<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽criteria.addOrder(Order.desc(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">postTime</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽totalCount聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽((Integer)聽criteria.setProjection(Projections.rowCount())<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽.uniqueResult()).intValue();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽criteria.setProjection(</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽items聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽criteria.setFirstResult(startIndex).setMaxResults(pageSize).list();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽blogs聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽ArrayList();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(Iterator聽ite聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽items.iterator();聽ite.hasNext();)聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Object[]聽objs聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(Object[])ite.next();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽blogs.add(objs[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽PaginationSupport聽ps聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽PaginationSupport(blogs,聽totalCount,聽pageSize,聽startIndex);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽ps;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽},聽</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">);<br />聽聽聽聽}</span></div>鍘熸潵闂灝卞湪Criteria.addOrder(Order.desc("postTime"));榪欏彞璇濈殑浣嶇疆涓婇潰錛宨nt totalCount = ((Integer) criteria.setProjection(Projections.rowCount())<br />聽聽聽聽聽聽.uniqueResult()).intValue();<br />榪欏彞璇濈殑鏃跺欏氨浼?xì)鐢熸垚涓婇潰閭e彞璇濆Q屽鏋滃湪榪欎箣鍓峚ddOrder灝變細(xì)鍑虹幇闂錛屽鏋滀綘鐢╩ysql涓嶄細(xì)鍑虹幇闂錛屽鏋滀綘鐢╯ql server灝變細(xì)鎶ラ敊銆傝В鍐蟲柟娉曞氨鏄妸addOrder璇彞鏀懼埌totalCount涓嬮潰灝卞彲浠ヤ簡(jiǎn)銆?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽PaginationSupport聽getBlogsByCategoryByPage(</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽String聽categoryId,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽startIndex,聽</span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽pageSize)聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽(PaginationSupport)聽getHibernateTemplate().execute(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽HibernateCallback()聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽Object聽doInHibernate(Session聽session)聽</span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000">聽HibernateException聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Criteria聽criteria聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽session.createCriteria(Blog.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Criteria聽cateCriteria聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽criteria.createCriteria(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">categories</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cateCriteria.add(Expression.eq(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,categoryId));<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽totalCount聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽((Integer)聽criteria.setProjection(Projections.rowCount())<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽.uniqueResult()).intValue();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽criteria.setProjection(</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽*聽Fix聽a聽bug聽,Order聽must聽add聽after聽get聽the聽totalCount,<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽*聽beacuse聽SqlServer聽not聽support聽order聽by聽in聽the聽select聽count(*).<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽criteria.addOrder(Order.desc(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">postTime</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽items聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽criteria.setFirstResult(startIndex).setMaxResults(pageSize).list();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽List聽blogs聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽ArrayList();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(Iterator聽ite聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽items.iterator();聽ite.hasNext();)聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Object[]聽objs聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(Object[])ite.next();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽blogs.add(objs[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽PaginationSupport聽ps聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽PaginationSupport(blogs,聽totalCount,聽pageSize,聽startIndex);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽ps;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽},聽</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">);<br />聽聽聽聽}</span></div><br />榪欐牱鐢熸垚鐨剆ql璇彞灝辨槸榪欐牱鐨勩?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">聽</span><span style="COLOR: #ff00ff">count</span><span style="COLOR: #000000">(</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">)聽</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">聽y0_聽</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">聽myblog_Blog聽this_聽</span><span style="COLOR: #0000ff">inner</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">join</span><span style="COLOR: #000000">聽myblog_Blog_Category聽categories3_聽</span><span style="COLOR: #0000ff">on</span><span style="COLOR: #000000">聽this_.id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">categories3_.blogId聽</span><span style="COLOR: #0000ff">inner</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">join</span><span style="COLOR: #000000">聽myblog_Category聽category1_聽</span><span style="COLOR: #0000ff">on</span><span style="COLOR: #000000">聽categories3_.categoryId</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">category1_.id聽</span><span style="COLOR: #0000ff">where</span><span style="COLOR: #000000">聽category1_.id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">?</span></div><br />浠ュ悗澶у涔熻娉ㄦ剰浜?jiǎn)銆傚懙鍛點(diǎn)?br /><img src ="http://m.tkk7.com/rory/aggbug/47339.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/rory/" target="_blank">鑾</a> 2006-05-21 22:49 <a href="http://m.tkk7.com/rory/archive/2006/05/21/47339.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>濡備綍緇檞ebwork鐨刟ction閲岀殑Field璁劇疆鍒濆鍊?緇?http://m.tkk7.com/rory/archive/2006/04/22/42463.html鑾鑾Sat, 22 Apr 2006 03:21:00 GMThttp://m.tkk7.com/rory/archive/2006/04/22/42463.htmlhttp://m.tkk7.com/rory/comments/42463.htmlhttp://m.tkk7.com/rory/archive/2006/04/22/42463.html#Feedback0http://m.tkk7.com/rory/comments/commentRss/42463.htmlhttp://m.tkk7.com/rory/services/trackbacks/42463.html濡備綍緇檞ebwork鐨刟ction閲岀殑Field璁劇疆鍒濆鍊?/a>

jdev璇村埌"涓轟粈涔堣鏀懼湪榪欓噷錛岃屼笉鏄斁鍒扮郴緇熼厤緗枃浠朵腑錛岀劧鍚庡湪緋葷粺璁劇疆鐣岄潰涓彁渚涜緗?錛屽悗鏉ユ垜灝辯敤spring鏉ユ敞鍏ヤ簡(jiǎn)銆傜幇鍦ㄥ氨鎶婂兼斁鍏roperties鏂囦歡涓簡(jiǎn)銆?br />

聽聽聽聽<bean聽id="propertyPlaceholderConfigurer"聽class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
聽聽聽聽聽聽
<property聽name="locations">
聽聽聽聽聽聽聽聽
<list>
聽聽聽聽聽聽聽聽聽聽
<value>classpath:mail.properties</value>
聽聽聽聽聽聽聽聽聽聽
<value>classpath:upload.properties</value>
聽聽聽聽聽聽聽聽
</list>
聽聽聽聽聽聽
</property>
聽聽聽聽
</bean>
聽聽聽聽
<!--聽鏀跺彂澶栭儴閭聽author:somebody-->
聽聽聽聽
<bean聽id="outMailManager"聽class="cn.com.fivefortunes.mail.manager.impl.OutMailManagerImpl">
聽聽聽聽聽聽聽聽
<property聽name="javaMailSender"><ref聽bean="javaMailSender"/></property>
聽聽聽聽聽聽聽聽
<property聽name="attachementDirectory"><value>${mail.attachementDirectory}</value></property>
聽聽聽聽聽聽聽聽
<property聽name="uploadFileDirectory"><value>${upload.directory}</value></property>
聽聽聽聽聽聽聽聽
<property聽name="outMailHibernateManager"><ref聽bean="outMailHibernateManager"/></property>
聽聽聽聽聽聽聽聽
<property聽name="outMailAccountManager"><ref聽bean="outMailAccountManager"/></property>
聽聽聽聽
</bean>
榪欐牱鎶妘ploadFileDirectory鏀懼叆mananger涓幓浜?jiǎn)銆傚湪properties閲岄潰閰嶇疆涓涓嬪氨ok浜?jiǎn)銆?br />

upload.directory
=D:\\tomcat5\\webapps\\files
mail.attachementDirectory
=D:\\tomcat5\\webapps\\files
涓婃榪樻湁緗戝弸榪欐牱璇村埌"return ServletActionContext.getServletContext().getRealPath("/");

浣犺繖鏍鋒崲浜?jiǎn)閮ň|茬幆澧冩瘡嬈¢兘瑕佹敼
鑰屼笖涔熻鏄?
D://tomcat5//webapps//files"
涔熻寰堝浜洪兘浠ヤ負(fù)榪欐槸鏈濂界殑鏂瑰紡錛屽彲鏄疄闄呮儏鍐典笉鏄繖鏍鳳紝鎴戜滑鐨剈ploadfile鐩綍宸茬粡鏈?G鐨勬枃浠訛紝鑰屽熀鏈笂姣忓ぉ鎴戜滑閮借鍙戝竷鏂扮殑webapp錛屽鏋滄妸uploadfile鐩綍鏀懼埌webapp鐨勪竴涓瓙鐩綍錛屾瘡嬈¢儴緗茬殑鏃跺欓兘瑕佸厛鎶妘ploadfile copy鍑烘潵鐒跺悗鍐嶉儴緗層傛墍浠ユ垜浠繖涔堝仛灝辨槸鎶妘pload鐩綍鏀懼埌鍏朵粬鐩綍涓嶅獎(jiǎng)鍝島ploadfile鐩綍閲岄潰鐨勬枃浠躲傚叧浜庢垜浠」鐩殑閮ㄧ講瑙佹垜鐨勪笅涓綃囨枃绔犮傝阿璋㈠ぇ瀹躲傚鏋滄?zhèn)ㄦ湁浠涔堟洿濂界殑鏂規(guī)硶璇鋒偍鎸囨暀銆?img src ="http://m.tkk7.com/rory/aggbug/42463.html" width = "1" height = "1" />

鑾 2006-04-22 11:21 鍙戣〃璇勮
]]>
spring鎿嶄綔鏁版嵁搴撳姝ょ畝鍗?/title><link>http://m.tkk7.com/rory/archive/2006/04/07/39699.html</link><dc:creator>鑾</dc:creator><author>鑾</author><pubDate>Thu, 06 Apr 2006 16:03:00 GMT</pubDate><guid>http://m.tkk7.com/rory/archive/2006/04/07/39699.html</guid><wfw:comment>http://m.tkk7.com/rory/comments/39699.html</wfw:comment><comments>http://m.tkk7.com/rory/archive/2006/04/07/39699.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://m.tkk7.com/rory/comments/commentRss/39699.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/rory/services/trackbacks/39699.html</trackback:ping><description><![CDATA[浠ュ墠涓鐩撮兘娌℃湁璇曡繃錛屽墠鍑犲ぉ鎵撶畻鎶妛ordpress鎹㈡垚鑷繁鍐欑殑紼嬪簭錛屽氨鎯沖埌浜?jiǎn)鏁版嵁鐨勫鍏ュ拰瀵煎嚭锛岄鍏堟儧_埌鐨勬槸鐢ㄦ暟鎹簱宸ュ叿鏉ュ銆傚彲鏄寰楁湁浜涢夯鐑?chǔ)锛屾垜鑷忿q殑紼嬪簭鏄敤spring+hibernate鐨勩傚悗鏉ユ垜灝辮瘯浜?jiǎn)涓涓媠pring鐨凧dbcTemplate,灝卞拰HibernateTemplate涓鏍風(fēng)殑濂界敤銆傞鍏堝鍔犱竴涓繛鎺ュ埌wp鏁版嵁搴撶殑dataSource <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">bean聽</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="dataSource2"</span><span style="COLOR: #ff0000">聽class</span><span style="COLOR: #0000ff">="org.springframework.jdbc.datasource.DriverManagerDataSource"</span><span style="COLOR: #ff0000">聽destroy-method</span><span style="COLOR: #0000ff">="close"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property聽</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="driverClassName"</span><span style="COLOR: #0000ff">><</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">org.hibernate.dialect.MySQLDialect</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property聽</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="url"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">jdbc:mysql://192.168.0.240:3306/wordpress蠅useUnicode=true</span><span style="COLOR: #ff0000">&amp;</span><span style="COLOR: #000000">characterEncoding=utf8</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property聽</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="username"</span><span style="COLOR: #0000ff">><</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">root</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property聽</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="password"</span><span style="COLOR: #0000ff">><</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />聽聽聽聽</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">></span></div><p>聽聽聽 鐒跺悗鍦ㄨ漿鎹㈢▼搴忛噷闈et榪欎釜dataSource錛宯ew 涓涓狫dbcTemplate(dataSource2)錛岃繖鏍峰氨ok浜?jiǎn)銆傚緢綆鍗曞惂銆?/p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">聽testCopyData()聽</span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000">聽Exception{<br />聽聽聽聽聽聽聽聽DataSource聽ds聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(DataSource)applicationContext.getBean(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">dataSource2</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽CategoryManager聽cateManager聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(CategoryManager)聽applicationContext.getBean(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">categoryManager</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽JdbcTemplate聽jt聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽JdbcTemplate(ds);<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Total聽posts:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">jt.queryForInt(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">select聽count(*)聽from聽wp_posts</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />聽聽聽聽聽聽聽聽assertNotNull(ds);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽List聽cates聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽jt.queryForList(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">select聽*聽from聽wp_categories</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(Iterator聽ite聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽cates.iterator();聽ite.hasNext();){<br />聽聽聽聽聽聽聽聽聽聽聽聽i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br />聽聽聽聽聽聽聽聽聽聽聽聽Map聽result聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(Map)聽ite.next();<br />聽聽聽聽聽聽聽聽聽聽聽聽Category聽cate聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">聽Category();<br />聽聽聽聽聽聽聽聽聽聽聽聽cate.setName((String)result.get(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">cat_name</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />聽聽聽聽聽聽聽聽聽聽聽聽cate.setOrder(i);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cate.setDefaultCategory(</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽聽聽聽聽cateManager.saveCategory(cate);<br />聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">cat_name:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">result.get(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">cat_name</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}</span></div><img src ="http://m.tkk7.com/rory/aggbug/39699.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/rory/" target="_blank">鑾</a> 2006-04-07 00:03 <a href="http://m.tkk7.com/rory/archive/2006/04/07/39699.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://www2019rz.com" target="_blank">亚洲AV网一区二区三区</a>| <a href="http://4388x4.com" target="_blank">永久免费无码日韩视频</a>| <a href="http://jcss99.com" target="_blank">皇色在线免费视频</a>| <a href="http://9196528.com" target="_blank">免费在线视频你懂的</a>| <a href="http://cshjjc.com" target="_blank">日本中文一区二区三区亚洲</a>| <a href="http://znboxcdn304.com" target="_blank">久久精品国产精品亚洲艾 </a>| <a href="http://www99383.com" target="_blank">亚洲处破女AV日韩精品</a>| <a href="http://hqshimo.com" target="_blank">亚洲国产乱码最新视频</a>| <a href="http://caoliushequ9.com" target="_blank">中文日本免费高清</a>| <a href="http://joob4s.com" target="_blank">成人免费看吃奶视频网站</a>| <a href="http://cfxzp.com" target="_blank">久久亚洲国产欧洲精品一 </a>| <a href="http://006dh.com" target="_blank">亚洲精品成a人在线观看☆</a>| <a href="http://66eeb.com" target="_blank">国产日韩AV免费无码一区二区 </a>| <a href="http://www-741.com" target="_blank">亚洲国产精品综合福利专区</a>| <a href="http://tuopumao.com" target="_blank">免费播放国产性色生活片</a>| <a href="http://sdsupuchem.com" target="_blank">0588影视手机免费看片</a>| <a href="http://hkcdk.com" target="_blank">亚洲中文字幕久久精品无码喷水 </a>| <a href="http://oakuu.com" target="_blank">亚洲福利一区二区</a>| <a href="http://ddm88888.com" target="_blank">一级毛片免费观看不收费</a>| <a href="http://3atv3523.com" target="_blank">国产成人免费网站</a>| <a href="http://www454yu.com" target="_blank">国产成A人亚洲精V品无码性色 </a>| <a href="http://mt569.com" target="_blank">亚洲AV成人精品日韩一区</a>| <a href="http://51porn3.com" target="_blank">亚洲精品在线免费观看</a>| <a href="http://eigakyuka.com" target="_blank">国产成人亚洲综合无码</a>| <a href="http://1444000.com" target="_blank">亚洲熟妇无码av另类vr影视 </a>| <a href="http://5gi555.com" target="_blank">久久久www成人免费毛片</a>| <a href="http://bx85.com" target="_blank">亚洲不卡av不卡一区二区</a>| <a href="http://79909d.com" target="_blank">黄色免费网址大全</a>| <a href="http://ccc998.com" target="_blank">性感美女视频免费网站午夜</a>| <a href="http://fuhui123.com" target="_blank">亚洲精品国产成人</a>| <a href="http://7a37.com" target="_blank">国产精品视频白浆免费视频</a>| <a href="http://hssw1688.com" target="_blank">亚洲精品无码成人片在线观看</a>| <a href="http://zhuguangbaoyu.com" target="_blank">亚洲一区免费视频</a>| <a href="http://zhxydq.com" target="_blank">99精品一区二区免费视频</a>| <a href="http://www-715111.com" target="_blank">精品国产亚洲男女在线线电影 </a>| <a href="http://hbgksy.com" target="_blank">国产av无码专区亚洲av果冻传媒</a>| <a href="http://cc58866.com" target="_blank">亚洲精品久久久久无码AV片软件</a>| <a href="http://htsp777.com" target="_blank">亚洲黄色免费电影</a>| <a href="http://www678678.com" target="_blank">亚洲av片劲爆在线观看</a>| <a href="http://116com.com" target="_blank">黄 色一级 成 人网站免费</a>| <a href="http://ksdhao.com" target="_blank">免费国产高清视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>