友情链接1:21点 足球投注 投注网 明升体育 hg0088 葡京赌场 网上赌球 诈金花 澳门金沙网址 澳门银河网址 澳门银河 澳门银河官网 银河官网 威尼斯人 澳门威尼斯人 澳门威尼斯人官网 威尼斯人官网 金沙 澳门金沙 澳门金沙官网 金沙官网 现金网 赌球网 全讯网 明升国际 足球开户 ******官网 ******网址 现金赌博 澳门现金网 ******官方网站

Java缂栫▼ | Mingo's Blog
鏃ュ織鍒嗙被锛欽ava缂栫▼

鎼缓Git鏈嶅姟鍣

鏃堕棿锛2016骞09鏈21鏃浣滆咃細Mingo琚洿瑙備簡锛712 娆璇勮娆℃暟锛0

绗竴姝ワ細瀹夎Git

$ ubuntu锛歴udo apt-get install git
# centos锛 yum install -y git

 

绗簩姝ワ細鍒涘缓涓涓猤it鐢ㄦ埛锛岀敤鏉ヨ繍琛実it鏈嶅姟

$ sudo adduser git

 

绗笁姝ワ細绂佺敤git鐢ㄦ埛鐨剆hell鐧诲綍

鍑轰簬瀹夊叏鑰冭檻锛岀浜屾鍒涘缓鐨刧it鐢ㄦ埛涓嶅厑璁哥櫥褰晄hell锛岃繖鍙互閫氳繃缂栬緫/etc/passwd鏂囦欢瀹屾垚銆傛壘鍒扮被浼间笅闈㈢殑涓琛岋細

$ git:x:1001:1001:,,,:/home/git:/bin/bash

鏇挎崲涓

$ git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

杩欐牱git鐢ㄦ埛灏变笉鑳絪hell鐧诲綍锛屼絾鏄繕鏄彲浠ラ氳繃ssh浣跨敤git鏈嶅姟銆

绗洓姝ワ細鍒濆鍖朑it浠撳簱

鍏堥夊畾涓涓洰褰曚綔涓篏it浠撳簱锛屽亣璁炬槸/home/git/repository/sample.git,鍦/home/git/repository/鐩綍涓嬭緭鍏ュ懡浠わ細

$ git init --bare sample.git
$ chown git:git sample.git

鎶妎wner鏀逛负git銆

绗簲姝ワ細clone 杩滅▼浠撳簱

root@ubuntu:/# git clone git@192.168.109.130/home/git/repositories/sample.git

fatal: repository ‘git@192.168.109.130/home/git/repositories/sample.git’ does not exist

root@ubuntu:/# git clone git@192.168.109.130:/home/git/repositories/sample.git

Cloning into ‘sample’…

The authenticity of host ’192.168.109.130 (192.168.109.130)’ can’t be established.

ECDSA key fingerprint is 32:f8:db:69:2a:1c:1a:d1:21:59:29:06:e4:1e:55:b1.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ’192.168.109.130′ (ECDSA) to the list of known hosts.

git@192.168.109.130′s password:

warning: You appear to have cloned an empty repository.

Checking connectivity… done.

 

 

 

 

 

 

 

 

 

 

 

 

杩欓噷鎻愮ず浣犺緭鍏ュ瘑鐮佹墠鑳絚lone锛屽綋鐒跺鏋滀綘鐭ラ亾瀵嗙爜锛屽彲浠ラ敭鍏ュ瘑鐮佹潵杩涜clone锛屼絾鏄洿涓哄父瑙佺殑鏂瑰紡锛屾槸鍒╃敤SSH鐨勫叕閽ユ潵瀹屾垚楠岃瘉銆

 

鍒涘缓SSH Key锛

棣栧厛鍦ㄧ敤鎴蜂富鐩綍涓嬶紝鐪嬬湅鏈夋病鏈.ssh鐩綍锛屽鏋滄湁锛屽啀鐪嬬湅杩欎釜鐩綍涓嬫湁娌℃湁id_rsa鍜宨d_rsa.pub杩欎袱涓枃浠讹紝濡傛灉宸茬粡鏈変簡锛屽彲鐩存帴璺冲埌涓嬩竴姝ャ傚鏋滄病鏈夛紝鎵撳紑Shell锛圵indows涓嬫墦寮Git Bash锛夛紝鍒涘缓SSH Key锛

 

ssh -keygen -t rsa -C "youremail@example.com"

youremail@example.com 鏇挎崲涓轰綘鑷繁鐨email

濡傛灉涓鍒囬『鍒╃殑璇濓紝鍙互鍦ㄧ敤鎴蜂富鐩綍閲屾壘鍒.ssh鐩綍锛岄噷闈㈡湁id_rsa鍜宨d_rsa.pub涓や釜鏂囦欢锛岃繖涓や釜灏辨槸SSH Key鐨勭閽ュ锛宨d_rsa鏄閽ワ紝涓嶈兘娉勯湶鍑哄幓锛宨d_rsa.pub鏄叕閽ワ紝鍙互鏀惧績鍦板憡璇変换浣曚汉銆

鏈嶅姟鍣ㄧ璁剧疆锛

鍦℅it鏈嶅姟鍣ㄤ笂娣诲姞浣犵殑鍏挜鐢ㄦ潵楠岃瘉浣犵殑淇℃伅浜嗐傞鍏堥渶瑕佸湪/etc/ssh/sshd_config涓皢RSA璁よ瘉鎵撳紑锛屽嵆锛

RSAAuthentication yes聽聽聽聽

PubkeyAuthentication yes
AuthorizedKeysFile聽 .ssh/authorized_keys

杩欓噷鎴戜滑鍙互鐪嬪埌鍏挜瀛樻斁鍦.ssh/authorized_keys鏂囦欢涓傛墍浠ユ垜浠湪/home/git涓嬪垱寤.ssh鐩綍锛岀劧鍚庡垱寤篴uthorized_keys鏂囦欢锛屽苟灏嗗垰鐢熸垚鐨勫叕閽ュ鍏ヨ繘鍘伙紝涓琛屼竴涓

鍒嗙被锛Java缂栫▼

java.lang.NoClassDefFoundError闂鍒嗘瀽鍙婅В鍐虫柟娉

鏃堕棿锛2014骞09鏈22鏃浣滆咃細Mingo琚洿瑙備簡锛1,526 娆璇勮娆℃暟锛0

java.lang.NoClassDefFoundError聽鏈壘鍒扮被瀹氫箟閿欒銆

褰揓ava铏氭嫙鏈烘垨鑰呯被瑁呰浇鍣ㄨ瘯鍥惧疄渚嬪寲鏌愪釜绫伙紝鑰屾壘涓嶅埌璇ョ被鐨勫畾涔夋椂鎶涘嚭璇ラ敊璇

 

瑙e喅鏂规硶锛

1銆佹鏌ユ槸鍚﹀皯jar鍖

2銆佹牴鎹悗闈㈢殑璺緞鎻愮ず锛屾鏌ユ槸涓嶆槸鏈夋湭瀹氫箟鐨勭被

3銆佸鏋滃凡缁忔湁姝ょ被锛岃繕鍦ㄦ姏杩欎釜寮傚父锛岃妫鏌ユ槸鍚︾紪璇戞垚鍔熴

鏍囩锛鍒嗙被锛Java缂栫▼

java.lang.ArrayIndexOutOfBoundsException寮傚父鍒嗘瀽鍙婅В鍐虫柟娉

鏃堕棿锛2014骞09鏈21鏃浣滆咃細Mingo琚洿瑙備簡锛1,236 娆璇勮娆℃暟锛0

杩欎釜寮傚父鐩镐俊寰堝鏈嬪弸涔熺粡甯搁亣鍒拌繃锛屽紓甯哥殑瑙i噴鏄暟缁勪笅鏍囪秺鐣岋紝鐜板湪绋嬪簭涓ぇ澶氶兘鏈夊鏁扮粍鐨勬搷浣滐紝鍥犳鍦ㄨ皟鐢ㄦ暟缁勭殑鏃跺欎竴瀹氳璁ょ湡妫鏌ワ紝鐪嬭嚜宸辫皟鐢ㄧ殑涓嬫爣鏄笉鏄秴鍑轰簡鏁扮粍鐨勮寖鍥达紝涓鑸潵璇达紝鏄剧ず锛堝嵆鐩存帴鐢ㄥ父鏁板綋涓嬫爣锛夎皟鐢ㄤ笉澶鏄撳嚭杩欐牱鐨勯敊锛屼絾闅愬紡锛堝嵆鐢ㄥ彉閲忚〃绀轰笅鏍囷級璋冪敤灏辩粡甯稿嚭閿欎簡锛岃繕鏈変竴绉嶆儏鍐碉紝鏄▼搴忎腑瀹氫箟鐨勬暟缁勭殑闀垮害鏄氳繃鏌愪簺鐗瑰畾鏂规硶鍐冲畾鐨勶紝涓嶆槸浜嬪厛澹版槑鐨勶紝杩欎釜鏃跺欙紝鏈濂藉厛鏌ョ湅涓涓嬫暟缁勭殑length锛屼互鍏嶅嚭鐜拌繖涓紓甯搞

鍒嗙被锛Java缂栫▼

JAVA闈㈣瘯棰

鏃堕棿锛2014骞09鏈20鏃浣滆咃細Mingo琚洿瑙備簡锛1,333 娆璇勮娆℃暟锛0

浼佷笟鍙戞斁鐨勫閲戞牴鎹埄娑︽彁鎴愩傚埄娑(I)浣庝簬鎴栫瓑浜10涓囧厓鏃讹紝濂栭噾鍙彁10%锛涘埄娑﹂珮浜10涓囧厓锛屼綆浜20涓囧厓鏃讹紝浣庝簬10涓囧厓鐨勯儴鍒嗘寜10%鎻愭垚锛岄珮浜10涓囧厓鐨勯儴鍒嗭紝鍙彲鎻愭垚7.5%锛20涓囧埌40涓囦箣闂存椂锛岄珮浜20涓囧厓鐨勯儴鍒嗭紝鍙彁鎴5%锛40涓囧埌60涓囦箣闂存椂楂樹簬40涓囧厓鐨勯儴鍒嗭紝鍙彁鎴3%锛60涓囧埌100涓囦箣闂存椂锛岄珮浜60涓囧厓鐨勯儴鍒嗭紝鍙彁鎴1.5%锛岄珮浜100涓囧厓鏃讹紝瓒呰繃100涓囧厓鐨勯儴鍒嗘寜1%鎻愭垚锛屼粠閿洏杈撳叆褰撴湀鍒╂鼎锛屾眰搴斿彂鏀惧閲戞绘暟锛

 

绛旀濡備笅锛

        public static void main(String[] args) {
		double x = 0, y = 0;
		System.out.print("杈撳叆褰撴湀鍒╂鼎锛堜竾锛夛細");
		Scanner s = new Scanner(System.in);
		x = s.nextInt();
		if (x > 0 && x <= 10) {
			y = x * 0.1;
		} else if (x > 10 && x <= 20) {
			y = 10 * 0.1 + (x - 10) * 0.075;
		} else if (x > 20 && x <= 40) {
			y = 10 * 0.1 + 10 * 0.075 + (x - 20) * 0.05;
		} else if (x > 40 && x <= 60) {
			y = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (x - 40) * 0.03;
		} else if (x > 60 && x <= 100) {
			y = 20 * 0.175 + 20 * 0.05 + 20 * 0.03 + (x - 60) * 0.015;
		} else if (x > 100) {
			y = 20 * 0.175 + 40 * 0.08 + 40 * 0.015 + (x - 100) * 0.01;
		}
		System.out.println("搴旇鎻愬彇鐨勫閲戞槸" + y + "涓");
	}

 

鏍囩锛,鍒嗙被锛Java缂栫▼

Eclipse姝e垯琛ㄨ揪寮 鎵归噺鏌ユ壘鏇挎崲 /* */ 娉ㄩ噴

鏃堕棿锛2014骞03鏈31鏃浣滆咃細Mingo琚洿瑙備簡锛2,913 娆璇勮娆℃暟锛0

鍦ㄧ敤jd-gui鍙嶇紪璇慗AVA椤圭洰鐨勬椂鍊欙紝鍙嶇紪璇戝嚭鏉ョ殑java鏂囦欢鍏ㄩ儴甯/* */娉ㄩ噴 锛岀湅鐫寰堜笉鐖姐傜綉涓婃壘浜嗕竴涓В鍐冲姙娉曪紝鏀惰棌涓涓嬶紒

闈炲父濂界敤銆

1锛孍clipse ctrl+f 鎵撳紑鏌ユ壘妗
2锛岄変腑 Regular expressions (姝e垯琛ㄨ揪寮)

鍘绘帀/* */锛坋clipse锛壜犅犅犅 /\*(.|[\r\n])*?\*/
鍘绘帀//锛坋clipse锛壜犅犅犅犅犅犅犅 //.*$
鍘绘帀import锛坋clipse锛壜犅犅犅 import.*$
鍘绘帀绌鸿锛坋clipse锛壜犅犅犅犅犅犅 ^\s*\n
鍘绘帀绌鸿锛坲e锛壜犅犅 %[ ^t]++^p

Hibernate 鑷畾涔塻ql 瀹炵幇澶氳〃鑱旀煡

鏃堕棿锛2012骞07鏈31鏃浣滆咃細Mingo琚洿瑙備簡锛13,567 娆璇勮娆℃暟锛2

濡備綍閫氳繃Hibernate 鑷畾涔塻ql 瀹炵幇澶氳〃鑱旀煡锛

鍦╤ibernate涓彧瑕佹槸閫氳繃鏄犲皠鍏崇郴鍏宠仈璧锋潵鐨凪odel,鍦ㄦ煡璇㈢殑鏃跺欓兘浼氭妸鎵鏈夊叧鑱旂殑Model鏌ュ嚭鏉,杩欐牱浼氶潪甯哥殑褰卞搷鏁堢巼锛岃櫧鐒舵湁寤惰繜妫绱㈣繖涓姛鑳斤紝浣嗘槸濡傛灉鎴戝彧闇瑕佹煡璇㈠嚑寮犺〃鐨勬煇鍑犱釜瀛楁鐨勮瘽锛岃繕鏄笉濂藉姙銆

鍥犳鎴戜滑闇瑕佽嚜瀹氫箟SQL銆傞偅涔堟垜浠浣曟妸鑷畾涔塖QL鏌ヨ鐨勭粨鏋滄斁杩汳odel閲岄潰鍛紵鑰岃繖涓粨鏋滀腑鐨凮bject鍙堝苟涓嶆槸宸叉湁鐨凪odel,鎵浠ヤ竴鑸垜浠細閲嶆柊鏂板缓涓涓狹odel銆傜敤鏉ュ瓨鏀炬煡璇㈢粨鏋,杩欎釜Model閲岄潰鐨勫瓧娈靛悕绉板繀椤诲拰鏁版嵁搴撶殑瀛楁鍚嶇О涓鑷达紙澶у皬鍐欎篃蹇呴』涓鑷达級銆

public List<TempModel> getListModel(){
     List<TempModel> list = new ArrayList<TempModel>();
     Session session = null;
     Transaction t = null;
     String sql = "select id,name from tb_User";
     try {
          session = getSessionFactory().openSession();
          t = session.beginTransaction();
          SQLQuery query = session.createSQLQuery(sql);
          //灏嗘煡璇㈢粨鏋滆浆鎹㈡垚List<Map<瀛楁鍚,瀛楁鍊>&gt map.KEY蹇呴』鍜孌B涓殑瀛楁涓鑷达紙澶у皬鍐欎篃蹇呴』锛;
          query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
          .addScalar("ID",Hibernate.LONG)  //杞崲绫诲瀷
          .addScalar("NAME", Hibernate.STRING);  //杞崲绫诲瀷
          //灏嗙粨鏋滆浆鎹㈡垚鎸囧畾鐨刡ean List<浣犵殑鎸囧畾javaBean>
          query.setResultTransformer(Transformers.aliasToBean(TempModel.class));
          list = query.list();
          t.commit();
     } catch (Exception e) {
          e.printStackTrace();
          t.rollback();
     } finally {
          t = null;
          session.close();
     }
     return list;
}
鏍囩锛,鍒嗙被锛Java缂栫▼

Ibatis涓叧浜<=鍜>=鐨勯厤缃柟娉

鏃堕棿锛2012骞07鏈03鏃浣滆咃細Mingo琚洿瑙備簡锛2,804 娆璇勮娆℃暟锛0

鎴戜滑鍦⊿QL涓粡甯镐細浣跨敤<=鎴栬>=绛夌鍙凤紝鍦╥batis涓璖QL閮芥槸鍐欏湪閰嶇疆鏂囦欢涓殑锛屽洜涓哄湪瑙f瀽XML鐨勬椂鍊欙紝濡傛灉鍑虹幇<=鎴栬>=,绋嬪簭浼氫互涓烘槸鏍囩鐨勫紑濮嬫垨缁撳熬锛屽洜姝ゅ鏋滆繖鏍烽厤缃細瀵艰嚧SQL鎶ラ敊銆

鍦╥batis涓甫<=鎴>=鐨勬纭啓娉曞涓嬶細


	
		= #startSeqNo#]]>
	
 


	
		

鏍囩锛鍒嗙被锛Java缂栫▼

java.lang.UnsupportedClassVersionError闂

鏃堕棿锛2012骞06鏈25鏃浣滆咃細Mingo琚洿瑙備簡锛2,343 娆璇勮娆℃暟锛0

褰撲綘鍙戠幇java.lang.UnsupportedClassVersionError闂锛屾槸鍥犱负鎴戜滑浣跨敤楂樼増鏈殑 JDK 缂栬瘧鐨 Java class 鏂囦欢璇曞浘鍦ㄨ緝浣庣増鏈殑 JVM 涓婅繍琛岋紝鎵鎶ョ殑閿欒銆

鍚屾椂浼氭湁杩欐牱涓涓俊鎭:Unsupported major.minor version 51.0

瑙e喅鍔炴硶锛氭墦寮exclipse涓」鐩笂鐨勫睘鎬р攋ava compiler鈥撻夋嫨涓涓悎閫傜殑鐗堟湰鍚庨噸鏂扮紪璇戝嵆鍙

 

鍒嗙被锛Java缂栫▼

OpenSessionInViewFilter 璇﹁В

鏃堕棿锛2012骞05鏈06鏃浣滆咃細Mingo琚洿瑙備簡锛7,914 娆璇勮娆℃暟锛3

openSessionInViewFilter鏄疭pring鎻愪緵鐨勪竴涓拡瀵笻ibernate鐨勪竴涓敮鎸佺被锛屽叾涓昏鎰忔濇槸鍦ㄥ彂璧蜂竴涓〉闈㈣姹傛椂鎵撳紑Hibernate鐨凷ession锛屼竴鐩翠繚鎸佽繖涓猄ession锛岀洿鍒拌繖涓姹傜粨鏉燂紝鍏蜂綋鏄氳繃涓涓狥ilter鏉ュ疄鐜扮殑銆

鐢变簬Hibernate寮曞叆浜哃azy Load鐗规э紝浣垮緱鑴辩Hibernate鐨凷ession鍛ㄦ湡鐨勫璞″鏋滃啀鎯抽氳繃getter鏂规硶鍙栧埌鍏跺叧鑱斿璞$殑鍊硷紝Hibernate浼氭姏鍑轰竴涓狶azyLoad鐨凟xception銆傛墍浠ヤ负浜嗚В鍐宠繖涓棶棰橈紝Spring寮曞叆浜嗚繖涓狥ilter锛屼娇寰桯ibernate鐨凷ession鐨勭敓鍛藉懆鏈熷彉闀裤

棣栧厛鍒嗘瀽涓涓嬪畠鐨勬簮鐮侊紝鍙互鍙戠幇锛屽畠鎵瀹炵幇鐨勫姛鑳藉叾瀹炴瘮杈冪畝鍗曪細

SessionFactory sessionFactory = lookupSessionFactory(request);
Session session = null;
boolean participate = false;   

if (isSingleSession()) {
    // single session mode
    if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
    // Do not modify the Session: just set the participate flag.
    participate = true;
       }    else {
    logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
    session = getSession(sessionFactory);
    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
    }
} else {
    // deferred close mode
    if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
// Do not modify deferred close: just set the participate flag.
    participate = true;
    } else {
    SessionFactoryUtils.initDeferredClose(sessionFactory);
    }
}   

try {
    filterChain.doFilter(request, response);
} finally {
    if (!participate) {
            if (isSingleSession()) {
                // single session mode
        TransactionSynchronizationManager.unbindResource(sessionFactory);
        logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
        closeSession(session, sessionFactory);
    }else {
        // deferred close mode
        SessionFactoryUtils.processDeferredClose(sessionFactory);
    }
}
}  

SessionFactory sessionFactory = lookupSessionFactory(request);
Session session = null;
boolean participate = false;

if (isSingleSession()) {
	// single session mode
	if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
	// Do not modify the Session: just set the participate flag.
	participate = true;
       }	else {
	logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter");
	session = getSession(sessionFactory);
	TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
	}
} else {
	// deferred close mode
	if (SessionFactoryUtils.isDeferredCloseActive(sessionFactory)) {
// Do not modify deferred close: just set the participate flag.
	participate = true;
    } else {
	SessionFactoryUtils.initDeferredClose(sessionFactory);
    }
}

try {
	filterChain.doFilter(request, response);
} finally {
	if (!participate) {
           	if (isSingleSession()) {
	         	// single session mode
		TransactionSynchronizationManager.unbindResource(sessionFactory);
		logger.debug("Closing single Hibernate Session in OpenSessionInViewFilter");
		closeSession(session, sessionFactory);
	}else {
		// deferred close mode
		SessionFactoryUtils.processDeferredClose(sessionFactory);
	}
}
}

 

鍦ㄤ笂杩颁唬鐮佷腑锛岄鍏堣幏寰桽essionFactory锛岀劧鍚庨氳繃SessionFactory鑾峰緱涓涓猄ession銆傜劧鍚庢墽琛岀湡姝g殑Action浠g爜锛屾渶鍚庢牴鎹儏鍐靛皢Hibernate鐨凷ession杩涜鍏抽棴銆傛暣涓濊矾姣旇緝娓呮櫚銆

娉ㄦ剰锛屽湪杩欓噷鏈変釜2涓猅ips锛
1锛夐氳繃getSession()鑾峰緱鐨勮繖涓猄ession鍋氫簡涓娆
session.setFlushMode(FlushMode.NEVER); 鏈夊叧FlushMode鍙互鍙傝冧竴涓嬭繖绡囨枃绔犮http://www2.matrix.org.cn/resource/article/2006-10-08/Hibernate+FlushMode+NEVER_312bca85-5699-11db-91a0-d98dff0aec60.html
2锛塖pring瀵规嬁鍒扮殑Session鍋氫簡涓娆$粦瀹氬埌褰撳墠绾跨▼鐨勫仛娉曪紝浣垮緱杩欎釜Session鏄嚎绋嬪畨鍏ㄧ殑銆

浠庝笂杩颁唬鐮佸叾瀹炲彲浠ュ緱鍒颁竴浜涘鎴戜滑鐨勫紑鍙戞湁甯姪鐨勭粨璁猴細
1锛夊鏋滀娇鐢ㄤ簡OpenSessionInView妯″紡锛岄偅涔圫pring浼氬府鍔╀綘绠$悊Session鐨勫紑鍜屽叧锛屼粠鑰屼綘鍦ㄤ綘鐨凞AO涓氳繃HibernateDaoSupport鎷垮埌鐨刧etSession()鏂规硶锛岄兘鏄粦瀹氬埌褰撳墠绾跨▼鐨勭嚎绋嬪畨鍏ㄧ殑Session锛屽嵆鎷垮嵆鐢紝鏈鍚庝細鐢盕ilter缁熶竴鍏抽棴銆
2锛夌敱浜庢嬁鍒扮殑Hibernate鐨凷ession琚缃簡session.setFlushMode(FlushMode.NEVER); 鎵浠ワ紝闄ら潪浣犵洿鎺ヨ皟鐢╯ession.flush()锛屽惁鍒橦ibernate session鏃犺浣曟椂涔熶笉浼歠lush浠讳綍鐨勭姸鎬佸彉鍖栧埌鏁版嵁搴撱傚洜姝わ紝鏁版嵁搴撲簨鍔$殑閰嶇疆闈炲父閲嶈銆傦紙鎴戜滑鐭ラ亾锛屽湪璋冪敤org.hibernate.Transaction.commit()鐨勬椂鍊欎細瑙﹀彂session.flush()锛夋垜鏇剧粡瑙佽繃寰堝浜哄湪浣跨敤OpenSessionInView妯″紡鏃讹紝閮藉洜涓烘病鏈夋纭厤缃簨鍔★紝瀵艰嚧浜嗗簳灞備細鎶涘嚭鏈夊叧FlushMode.NEVER鐨勫紓甯搞

OpenSessionInView杩欎釜妯″紡浣跨敤姣旇緝绠鍗曪紝涔熸垚涓轰簡澶у鍦╓eb寮鍙戜腑缁忓父浣跨敤鐨勬柟娉曪紝涓嶈繃瀹冩湁鏃跺欎細甯︽潵涓浜涙剰鎯充笉鍒扮殑闂锛岃繖涔熸槸鍦ㄥ紑鍙戜腑闇瑕佹敞鎰忕殑銆
1. 鍦⊿truts锛婼pring锛婬ibernate鐜涓紝鐢变簬閰嶇疆鐨勯棶棰樺鑷寸殑妯″紡澶辨晥
杩欎釜闂浠ュ墠璁哄潧鏇剧粡璁ㄨ杩囷紝鍙互鍙傝冧竴涓嬩笅闈㈣繖涓笘瀛愶細
http://www.iteye.com/topic/15057

2. OpenSessionInView鐨勬晥鐜囬棶棰
杩欎釜闂涔熸湁浜哄湪璁哄潧鎻愬嚭杩囷紝Robbin鏇剧粡鍋氳繃鍏蜂綋鐨勬祴璇曪紝鍙互鍏蜂綋鍙傝冧竴涓嬩笅闈㈣繖涓笘瀛愶細
http://www.iteye.com/topic/17501

3. 鐢变簬浣跨敤浜哋penSessionInView妯″紡鍚庨犳垚浜嗗唴瀛樺拰鏁版嵁搴撹繛鎺ラ棶棰
杩欎釜闂鏄垜鍦ㄧ敓浜х幆澧冧腑纰板埌鐨勪竴涓棶棰樸傜敱浜庝娇鐢ㄤ簡OpenSessionInView妯″紡锛孲ession鐨勭敓鍛藉懆鏈熷彉寰楅潪甯搁暱銆傝櫧鐒惰В鍐充簡Lazy Load鐨勯棶棰橈紝浣嗘槸甯︽潵鐨勯棶棰樺氨鏄疕ibernate鐨勪竴绾х紦瀛橈紝涔熷氨鏄疭ession绾у埆鐨勭紦瀛樼殑鐢熷懡鍛ㄦ湡浼氬彉寰楅潪甯搁暱锛岄偅涔堝鏋滀綘鍦ㄤ綘鐨凷ervice灞傚仛澶ф壒閲忕殑鏁版嵁鎿嶄綔鏃讹紝鍏跺疄杩欎簺鏁版嵁浼氬湪缂撳瓨涓繚鐣欎竴浠斤紝杩欐槸闈炲父鑰楄垂鍐呭瓨鐨勩傝繕鏈変竴涓暟鎹簱杩炴帴鐨勯棶棰橈紝瀛樺湪鐨勫師鍥犲湪浜庣敱浜庢暟鎹簱鐨凜onnection鏄拰Session缁戝湪涓璧风殑锛屾墍浠ワ紝Connection涔熶細寰椾笉鍒板強鏃剁殑閲婃斁銆傚洜鑰屽綋绯荤粺鍑虹幇涓氬姟闈炲父绻佸繖锛岃岃绠楅噺鍙堥潪甯稿ぇ鐨勬椂鍊欙紝寰寰鏁版嵁杩炴帴姹犵殑杩炴帴鏁颁細涓嶅銆傝繖涓棶棰樻垜鑷充粖闈炲父澶寸棝锛屽洜涓烘湁寰堝瀹㈡埛瀵规暟鎹繛鎺ユ睜鐨勬暟閲忎細鏈夐檺鍒讹紝涓嶄細缁欎綘鏃犻檺鍒剁殑澧炲姞涓嬪幓銆

4. 浣跨敤浜哋penSessionInView妯″紡浠ュ悗鍙栨暟鎹殑浜嬪姟闂
鍦ㄤ娇鐢ㄤ簡OpenSessionInView浠ュ悗锛屽叾瀹炰簨鍔$殑鐢熷懡鍛ㄦ湡姣擲ession鐨勭敓鍛藉懆鏈熸潵寰楃煭锛屽氨浠ヤ负鐫锛屽叾瀹炴湁鐩稿綋涓閮ㄥ垎鐨勬煡璇㈡槸涓嶈绾冲叆鍒颁簨鍔$殑鑼冨洿鍐呯殑锛屾鏃舵槸鍚︿細璇诲埌鑴忔暟鎹紵杩欎釜闂鎴戣嚦浠婁笉鏁㈢‘璁わ紝鏈夌粡楠岀殑鏈嬪弸璇锋寚鏁欎竴涓嬨

鏈鍚庢彁涓涓婳penSessionInView妯″紡鐨勪竴浜涙浛浠f柟妗堬紝鍙互浣跨敤OpenSessionInViewInterceptor鏉ヤ唬鏇胯繖涓狥ilter锛屾鏃跺彲浠ヤ娇鐢⊿pring鐨凙OP閰嶇疆锛屽皢杩欎釜Interceptor閰嶇疆鍒颁綘鎵闇瑕佺殑灞傛涓婂幓銆傚彟澶栧氨鏄彧鑳戒娇鐢ㄦ渶鍙よ佺殑Hibernate.initialize()鏂规硶杩涜鍒濆鍖栦簡銆

java.lang.IllegalArgumentException瑙e喅鍔炴硶

鏃堕棿锛2012骞04鏈06鏃浣滆咃細Mingo琚洿瑙備簡锛104,961 娆璇勮娆℃暟锛0

java.lang.IllegalArgumentException: Path index.jsp does not start with a 鈥/鈥 character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
model.MyActionServlet.process(MyActionServlet.java:22)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

閭d箞锛岃娉ㄦ剰浜嗐備綘鐨剆truts-config.xml鏂囦欢涓瀹氭槸鍑洪敊浜嗭紝灏变粩缁嗙湅鐪<action-mappings /> 鍚э紒
鐗瑰埆鏄<action>閲岄潰
path=鈥/admin/news鈥
<input=鈥/xxx.jsp鈥 >
<forward name=鈥漵uccess鈥 path=鈥/tran.jsp鈥 />

濡<input=鈥漧ogon.jsp鈥>銆銆锛濓紳锛瀒nput=鈥/logon.jsp鈥>
path=鈥漚dmin/news鈥澛犅犅犅 ==>path=鈥/admin/news鈥
<forward name=鈥漵uccess鈥 path=鈥漷ran.jsp鈥 /> ==><forward name=鈥漵uccess鈥 path=鈥/tran.jsp鈥 />

鏈夋椂锛屼笉涓瀹氭槸閰嶇疆鏂囦欢鍑虹殑閿欍傜湅鐪嬩綘鐨凙ction涓殑execute()鏂规硶锛

鐗瑰埆鏄痳etrun mapping.findForward(鈥淴XXXXXXXXXX鈥),
鎴戜粖澶╁氨閿欏湪杩欓噷浜嗭紝鏈潵鐨勬剰鎬濇槸return mapping.findForward(鈥渆ditnews鈥);
鍙垜鍗村啓鎴恟eturn new ActionForward(鈥渘ewslist鈥);鍏跺疄杩欏彞涔熷锛堝鏀惧湪鍒犻櫎鎴栬呮坊鍔犲悗闈㈢殑 璺宠浆 锛夛紝鍙笉杩囨斁鍦ㄨ繖閲屽氨涓嶅浜嗭紝鍥犱负鎴戠殑鈥漞ditnews鈥濆湪閰嶇疆鏂囦欢閲屽凡缁忓畾涔夎繃鍒悕浜

<forward name=鈥漞ditnews鈥 path=鈥/admin/newsedit.jsp鈥 />

锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳锛濓紳
鍒濆struts鏈変簺闂瑕佹敞鎰忥紒
鎴戝湪杩欓噷璇翠竴浜涙瘮杈冪粏鐨勫湴鏂癸紝閮芥槸鎴戦亣鍒拌繃鐨勶紝鍏朵粬鏂归潰缃戜笂涔︿笂閮借寰楀緢璇︾粏浜嗐
struts-config.xml鏂囦欢锛岃繖鏄緢閲嶈鐨勫湴鏂癸紝鎴愯触鐨勫叧閿晩锛侊紒
涓鑸殑鏍峰紡灏辨槸杩欐牱,绾㈣壊閮ㄥ垎瑕佹敞鎰
<?xml version=鈥1.0″ encoding=鈥漊TF-8″?>
<!DOCTYPE struts-config PUBLIC 鈥-//Apache Software Foundation//DTD Struts Configuration 1.1//EN鈥 鈥渉ttp://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd鈥>

<struts-config>
<data-sources />
<form-beans >
<form-bean name=鈥漸serLoginForm鈥 type=鈥漜om.yourcompany.struts.form.UserLoginForm鈥 />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action

——铏界劧鍦‥clipse寮鍙戝綋涓紝椤哄簭涓嶆槸杩欐牱锛屼絾鏄嚭闂鏃跺彲浠ヨ冭檻鍏堟敼杩欓噷鐨勯『搴忥紝鎴戣瘯杩囧湪杩欓噷鏀逛簡浠ュ悗闂瑙e喅浜嗐
attribute=鈥漸serLoginForm鈥
input=鈥/userLogin.jsp鈥
name=鈥漸serLoginForm鈥
path=鈥/userLogin鈥
scope=鈥漴equest鈥
type=鈥漜om.yourcompany.struts.action.UserLoginAction鈥
validate=鈥漟alse鈥>

——-鈥/鈥濊繖涓篃瑕佹敞鎰忥紝鎴戝湪缃戜笂鎵鹃敊鐨勬椂鍊欙紝鍙戠幇鏈変笉灏戜篃鏈夎繖涓敊璇Path 鏂囦欢鍚嶅瓧 does not start with a 鈥/鈥 character 璁板緱鍔犫/鈥濊繖涓紝寰堝鏄撳氨蹇樿锛屾垜鏄繛缁繕璁颁簡涓ゆ锛

 

鍒嗙被锛Java缂栫▼