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

Java | Mingo's Blog
鏃ュ織鏍囩锛歫ava

JAVA闈㈣瘯棰

鏃堕棿锛2014骞09鏈20鏃浣滆咃細Mingo琚洿瑙備簡锛1,321 娆璇勮娆℃暟锛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,893 娆璇勮娆℃暟锛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

OpenSessionInViewFilter 璇﹁В

鏃堕棿锛2012骞05鏈06鏃浣滆咃細Mingo琚洿瑙備簡锛7,863 娆璇勮娆℃暟锛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鐢熸垚楠岃瘉鐮

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

Java鐢熸垚楠岃瘉鐮 浠g爜濡備笅锛

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Random;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.qy.pro.util.Constant;

public class CheckCodeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	// 楠岃瘉鐮佸浘鐗囩殑瀹藉害銆
		private int width = 60;
		// 楠岃瘉鐮佸浘鐗囩殑楂樺害銆
		private int height = 16;

		protected void service(HttpServletRequest req, HttpServletResponse resp)
				throws ServletException, java.io.IOException {
			BufferedImage buffimg = new BufferedImage(width, height,
					BufferedImage.TYPE_INT_RGB);
			Graphics2D g = buffimg.createGraphics();
			// 鍒涘缓涓涓殢鏈烘暟鐢熸垚鍣ㄧ被銆
			Random random = new Random();
			g.setColor(Color.white);
			g.fillRect(0, 0, width, height);

			// 鍒涘缓瀛椾綋锛屽瓧浣撶殑澶у皬搴旇鏍规嵁鍥剧墖鐨勯珮搴︽潵瀹氥
			Font font = new Font("times new roman", Font.PLAIN, 20);
			// 璁剧疆瀛椾綋銆
			g.setFont(font);

			// 鐢昏竟妗嗐
			g.setColor(Color.white);
			g.drawRect(0, 0, width - 1, height - 1);

			// 闅忔満浜х敓10鏉″共鎵扮嚎锛屼娇鍥捐薄涓殑璁よ瘉鐮佷笉鏄撹鍏跺畠绋嬪簭鎺㈡祴鍒般
			g.setColor(Color.gray);
			for (int i = 0; i < 5; i++) {
				int x = random.nextInt(width);
				int y = random.nextInt(height);
				int xl = random.nextInt(12);
				int yl = random.nextInt(12);
				g.drawLine(x, y, x + xl, y + yl);
			}

			// randomcode鐢ㄤ簬淇濆瓨闅忔満浜х敓鐨勯獙璇佺爜锛屼互渚跨敤鎴风櫥褰曞悗杩涜楠岃瘉銆
			StringBuffer randomcode = new StringBuffer();
			int red = 0, green = 0, blue = 0;

			// 闅忔満浜х敓4浣嶆暟瀛楃殑楠岃瘉鐮併
			for (int i = 0; i < 4; i++) {
				// 寰楀埌闅忔満浜х敓鐨勯獙璇佺爜鏁板瓧銆
				String strrand = "";
//				int n = random.nextInt(123);
				int n = random.nextInt(10);
				if (n >= 65) // 濡傛灉澶т簬65鍒欒浆鎹负涓涓瓧绗
				{
					if (n > 90 && n < 97) { // 濡傛灉涓轰笉鍚堟硶鐨勫瓧绗﹀垯鍐嶈浆涓烘暟瀛
						n = random.nextInt(10);
						strrand += n;
					} else { // 鐢熸垚涓涓瓧绗
						strrand = (char) n + "";
					}
				} else {
					n = random.nextInt(10);
					strrand += n;
				}
				// 浜х敓闅忔満鐨勯鑹插垎閲忔潵鏋勯犻鑹插硷紝杩欐牱杈撳嚭鐨勬瘡浣嶆暟瀛楃殑棰滆壊鍊奸兘灏嗕笉鍚屻
				red = random.nextInt(200);
				green = random.nextInt(200);
				blue = random.nextInt(200);

				// 浜х敓闅忔満楂樺害 10鑷砲eight涔嬮棿
				float imght = 0;
				while (imght <= 13) {
					imght = Float
							.parseFloat(String.valueOf(random.nextInt(height)));
				}
				// 鐢ㄩ殢鏈轰骇鐢熺殑棰滆壊灏嗛獙璇佺爜缁樺埗鍒板浘鍍忎腑銆
				g.setColor(new Color(red, green, blue));
				g.drawString(strrand, 13 * i+10, imght);

				// 灏嗕骇鐢熺殑鍥涗釜闅忔満鏁扮粍鍚堝湪涓璧枫
				randomcode.append(strrand);
			}
			g.dispose();
			// 灏嗗洓浣嶆暟瀛楃殑楠岃瘉鐮佷繚瀛樺埌session涓傚叾閿负 validateCode
			HttpSession session = req.getSession();
			session.setAttribute(Constant.CHECK_CODE, randomcode.toString());

			// 绂佹鍥惧儚缂撳瓨銆
			resp.setHeader("pragma", "no-cache");
			resp.setHeader("cache-control", "no-cache");
			resp.setDateHeader("expires", 0);
			resp.setContentType("image/png");

			// 灏嗗浘鍍忚緭鍑哄埌servlet杈撳嚭娴佷腑銆
			ServletOutputStream sos = resp.getOutputStream();
			try{
			ImageIO.write(buffimg, "png", sos);
			}catch(Exception c){}
			sos.close();
		}

}

 

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

Java Webservice涔媂Fire鐨勫鎴风璋冪敤

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

鍓嶉潰鎴戜滑璇村埌Java Webservice涔媂Fire寤虹珛鏈嶅姟鍣ㄧ锛岃繖閲屾垜浠湅鐪嬫庝箞鍦ㄥ鎴风璋冪敤Webservice鐨勪袱绉嶆柟寮
涓銆侀氳繃鏈嶅姟绔彁渚涚殑鎺ュ彛绫昏繘琛岃皟鐢ㄣ
浠g爜濡備笅锛

package com.xfire.client;

import java.net.MalformedURLException;
import java.util.List;

import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

import com.xfire.domain.Person;
import com.xfire.spring.IPersonService;

public class PojoInvokeClient {

  public static void main(String[] args) {
        Service serviceModel = new ObjectServiceFactory().create(IPersonService.class);
        XFire xfire = XFireFactory.newInstance().getXFire();
        XFireProxyFactory factory = new XFireProxyFactory(xfire);
        String serviceUrl = "http://127.0.0.1:8080/xfire/services/PersonService";
        IPersonService client = null;
        try {
              client = (IPersonService) factory.create(serviceModel, serviceUrl);
        } catch (MalformedURLException e) {
              System.out.println("Client call webservice has exception: "+ e.toString());
        }
        String result1 =client.sayHello("寮犱笁");
  }
}

浜屻佺洿鎺ラ氳繃url璋冪敤, 涓嶇敤瀹㈡埛绔彁渚涙帴鍙g被銆

package com.xfire.client;

import java.net.MalformedURLException;
import java.net.URL;

import org.codehaus.xfire.client.Client;

public class UrlInvokeClient {

  public static void main(String[] args) {
    Client client = null;
    try {
      client = new Client(new URL("http://127.0.0.1:8080/xfire/PersonService.ws?wsdl"));
      Object[] result1 = client.invoke("sayHello", new Object[] {"寮犱笁"});
      System.out.println(result1[0]);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

 

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

2012骞3鏈堢紪绋嬭瑷鎺掕姒滐細C鏈夋湜瓒呰秺Java

鏃堕棿锛2012骞03鏈12鏃浣滆咃細Mingo琚洿瑙備簡锛36,478 娆璇勮娆℃暟锛1

TIOBE杩戞棩鍏竷浜2012骞3鏈堜唤鐨勭紪绋嬭瑷鎺掕姒滐紝涓婁釜鏈堟帓鍚嶇10鐨凧avaScript宸茬粡瓒呰秺浜哖ython鍜孭erl锛屽崌鑷崇8锛岄櫎姝や箣澶栵紝鍓嶅崄浣嶇殑鍏朵粬缂栫▼璇█鐨勬帓鍚嶅苟娌℃湁浠涔堝彉鍖栥
鐩墠锛屽墠涓ゅ悕鐨勪綅缃粛鐢盝ava銆丆鍜孋#鎵鍗犳嵁锛屽煎緱娉ㄦ剰鐨勬槸锛孞ava鍜孋涔嬮棿鐨勫樊璺濊繘涓姝ョ缉灏忥紝浠庝笂涓湀鐨0.527%闄嶈嚦0.023%锛岃屾牴鎹袱鑰呯殑澧為熸潵鐪嬶紝C鏈夋湜鍦ㄦ湭鏉ョ殑涓や釜鏈堣秴瓒奐ava锛屾垚涓哄啝鍐涖

缂栫▼璇█鎺掕姒

鏍囩锛,,鍒嗙被锛涓氱晫璧勮

Java WebService 涔媂Fire寤虹珛鏈嶅姟鍣ㄧ

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

1銆侀鍏堜笅杞芥墍闇瑕佺殑xfire鏀寔搴搙fire-distribution-1.2.6.zip锛屼笅杞藉湴鍧锛涓嬭浇涓 聽聽 涓嬭浇浜

2銆佺敤eclipse鏂板缓涓涓猈eb宸ョ▼銆傚鍏ユ敮鎸佸簱涓璴ib涓嬬殑鎵鏈夊寘鍜寈fire-all-1.2.6.jar鍒版垜浠伐绋嬬殑lib鐩綍涓嬨

3銆佷慨鏀筗eb宸ョ▼涓嬬殑web.xml鏂囦欢, 鍔犲叆浠ヤ笅浠g爜鍗冲彲

 

<servlet>
   <servlet-name>XFireServlet</servlet-name>
   <display-name>XFire
    Servlet</display-name>
   <servlet-class>
    org.codehaus.xfire.transport.http.XFireConfigurableServlet
   </servlet-class>
  </servlet>
  <servlet-mapping>
   <servlet-name>XFireServlet</servlet-name>
   <url-pattern>/servlet/XFireServlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
   <servlet-name>XFireServlet</servlet-name>
   <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

4銆佸缓绔嬩竴涓櫘閫氱被鐢ㄤ簬鏄犲皠瀵瑰簲web鏈嶅姟涓句緥濡備笅:

public class BeanService {

  public String sayHello(String name) {
    return "浣犲ソ:"+ name;
  }
}

5銆佸湪宸ョ▼鐨剆rc涓嬪缓/src/META-INF/xfire/services.xml鏂囦欢,鍐呭濡備笅:

<beans>
 <service xmlns="http://xfire.codehaus.org/config/1.0">
  <name>BeanService</name>
  <namespace>http://xiaozhong/BeanServices</namespace>
  <serviceClass>com.xfire.services.BeanService</serviceClass>
 </service>
</beans>

6銆佸彂甯冨苟鍚姩鏈嶅姟鍣ㄣ傝闂http://localhost:8080/xfire/services灏卞彲浠ョ湅鍒版垜浠綋鍓嶅伐绋嬩腑鏈嶅姟鐨勫垪琛ㄣ傜偣鍑诲悗闈㈢殑wsdl灏卞彲浠ョ湅鍒版湇鍔$殑wsdl鏂囦欢浜嗐

 

 

 

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

java.lang.String.format 鐨勪娇鐢ㄨ瑙

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

java.lang.String.format 鐨勪娇鐢ㄨ瑙o細

/**
聽 * 1銆丼tring.format(String fmt,Object… objs)
聽 * 聽fmt: 鏍煎紡鎴愪粈涔堟牱鐨勬牸寮
聽 * 聽objs锛氶渶瑕佹牸寮忓寲鐨勭洰褰曞璞℃敮鎸佹暟鍊笺佸瓧绗︿覆銆佹棩鏈
聽 * 娉ㄦ剰锛歫dk1.5鍙婂叾浠ヤ笂鐗堟湰鎵嶆湁姝ゆ柟娉曘
聽 *
聽 * 2銆乫mt鐨勭紪鍐欐柟寮
聽 * 聽鈶:甯歌銆佹暣鏁般佹诞鐐圭被鍨
聽 * 聽聽%寮濮+寮曠敤鐨刼bjs绗嚑涓$(闈炲繀閫)+0(涓嶈冻浣嶆寜0濉厖,闈炲繀閫)+浜х敓浣嶆暟(濡傛灉鏍煎紡鍖栦负娴偣鏁板垯涓衡滄讳綅鏁.灏忔暟浣嶆暟鈥,闈炲繀閫)+绫诲瀷淇グ绗
聽 * 聽聽濡傦細%1$3d銆%1$04d銆%2$5.2f
聽 * 聽鈶:鏃堕棿绫诲瀷
聽 * 聽聽%寮濮+寮曠敤鐨刼bjs绗嚑涓$(闈炲繀閫)+鏃堕棿鍓嶇紑(t/T)+绫诲瀷淇グ绗
聽 * 聽聽濡傦細%1$tY銆%1$tm銆%1$td銆%1$tH銆%1$tM銆%1$tS
聽 * 娉ㄦ剰锛氬鏋滀笉鍐欑浜岄儴鍒(寮曠敤鐨刼bjs绗嚑涓$), 鍒欓粯璁ゆ寜浣跨敤%寮濮嬬殑鏁伴噺渚濇澧炲姞涓(寤鸿鍐欎笂)銆
聽 *
聽 * 3銆佺被鍨嬩慨楗扮(鎽樿嚜jdk)
聽 * 聽聽聽 杞崲聽 聽鍙傛暟绫诲埆 聽聽聽 璇存槑聽
聽 *聽——–|———-|———————————–
聽 * 聽’b', ‘B’聽 甯歌聽 聽濡傛灉鍙傛暟 arg 涓 null锛屽垯缁撴灉涓 鈥渇alse鈥濄傚鏋 arg 鏄竴涓 boolean 鍊兼垨 Boolean锛屽垯缁撴灉涓 String.valueOf() 杩斿洖鐨勫瓧绗︿覆銆傚惁鍒欑粨鏋滀负 鈥渢rue鈥濄偮
聽 * 聽’h', ‘H’聽 甯歌聽 聽濡傛灉鍙傛暟 arg 涓 null锛屽垯缁撴灉涓 鈥渘ull鈥濄傚惁鍒欙紝缁撴灉涓鸿皟鐢 Integer.toHexString(arg.hashCode()) 寰楀埌鐨勭粨鏋溿偮
聽 * 聽’s', ‘S’聽 甯歌聽 聽濡傛灉鍙傛暟 arg 涓 null锛屽垯缁撴灉涓 鈥渘ull鈥濄傚鏋 arg 瀹炵幇 Formattable锛屽垯璋冪敤 arg.formatTo銆傚惁鍒欙紝缁撴灉涓鸿皟鐢 arg.toString() 寰楀埌鐨勭粨鏋溿偮
聽 * 聽’c', ‘C’聽 瀛楃聽 聽缁撴灉鏄竴涓 Unicode 瀛楃聽
聽 * 聽’d'聽聽聽聽聽聽 鏁存暟 聽缁撴灉琚牸寮忓寲涓哄崄杩涘埗鏁存暟聽
聽 * 聽’o'聽聽聽聽聽聽 鏁存暟聽 聽缁撴灉琚牸寮忓寲涓哄叓杩涘埗鏁存暟聽
聽 * 聽’x', ‘X’聽 鏁存暟 聽 缁撴灉琚牸寮忓寲涓哄崄鍏繘鍒舵暣鏁奥
聽 * 聽’e', ‘E’聽 娴偣 聽 缁撴灉琚牸寮忓寲涓虹敤璁$畻鏈虹瀛﹁鏁版硶琛ㄧず鐨勫崄杩涘埗鏁奥
聽 * 聽’f'聽聽聽聽聽聽 娴偣 聽 缁撴灉琚牸寮忓寲涓哄崄杩涘埗鏁奥
聽 * 聽’g', ‘G’聽 娴偣聽 聽鏍规嵁绮惧害鍜岃垗鍏ヨ繍绠楀悗鐨勫硷紝浣跨敤璁$畻鏈虹瀛﹁鏁板舰寮忔垨鍗佽繘鍒舵牸寮忓缁撴灉杩涜鏍煎紡鍖栥偮
聽 * 聽’a', ‘A’聽 娴偣聽 聽缁撴灉琚牸寮忓寲涓哄甫鏈夋晥浣嶆暟鍜屾寚鏁扮殑鍗佸叚杩涘埗娴偣鏁奥
聽 * 聽’t', ‘T’聽 鏃ユ湡/鏃堕棿聽聽 聽鏃ユ湡鍜屾椂闂磋浆鎹㈠瓧绗︾殑鍓嶇紑銆傝鍙傞槄鏃ユ湡/鏃堕棿杞崲銆偮
聽 * 聽’%'聽聽聽聽聽聽 鐧惧垎姣斅 聽缁撴灉涓哄瓧闈㈠ ‘%’ (‘\u0025′)聽
聽 * 聽’n'聽聽聽聽聽聽 琛屽垎闅旂聽 聽缁撴灉涓虹壒瀹氫簬骞冲彴鐨勮鍒嗛殧绗β
聽 *
聽 * 4銆佹椂闂寸被鍨嬩慨楗扮(鎽樿嚜jdk)
聽 * 淇グ绗β犅犅犅 |聽璇存槑
聽 * ———|————————————-
聽 * ‘H’聽聽聽聽聽聽聽聽 聽|聽24 灏忔椂鍒剁殑灏忔椂锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涓や綅鏁帮紝鍗 00 – 23銆偮
聽 * ‘I’聽聽聽聽聽聽聽聽聽聽聽|聽12 灏忔椂鍒剁殑灏忔椂锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涓や綅鏁帮紝鍗 01 – 12銆偮
聽 * ‘k’聽 聽聽聽聽聽聽聽聽 |聽24 灏忔椂鍒剁殑灏忔椂锛屽嵆 0 – 23銆偮
聽 * ‘l’聽 聽聽聽聽聽聽聽聽聽 |聽12 灏忔椂鍒剁殑灏忔椂锛屽嵆 1 – 12銆偮
聽 * ‘M’聽 聽聽聽聽聽聽 |聽灏忔椂涓殑鍒嗛挓锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涓や綅鏁帮紝鍗 00 – 59銆偮
聽 * ‘S’聽 聽聽聽聽聽聽聽 |聽鍒嗛挓涓殑绉掞紝琚牸寮忓寲涓哄繀瑕佹椂甯﹀墠瀵奸浂鐨勪袱浣嶆暟锛屽嵆 00 – 60 锛堚60″ 鏄敮鎸侀棸绉掓墍闇鐨勪竴涓壒娈婂硷級銆偮
聽 * ‘L’聽聽聽聽聽聽聽聽 聽|聽 绉掍腑鐨勬绉掞紝琚牸寮忓寲涓哄繀瑕佹椂甯﹀墠瀵奸浂鐨勪笁浣嶆暟锛屽嵆 000 – 999銆偮
聽 * ‘N’聽 聽聽聽聽聽聽 |聽聽 绉掍腑鐨勬寰锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涔濅綅鏁帮紝鍗 000000000 – 999999999銆偮
聽 * ‘p’聽 聽聽聽聽聽聽 |聽 鐗瑰畾浜庤瑷鐜鐨 涓婂崍鎴栦笅鍗 鏍囪浠ュ皬鍐欏舰寮忚〃绀猴紝渚嬪 鈥渁m鈥 鎴 鈥減m鈥濄備娇鐢ㄨ浆鎹㈠墠缂 ‘T’ 鍙互寮鸿灏嗘杈撳嚭杞崲涓哄ぇ鍐欏舰寮忋偮
聽 * ‘z’聽 聽聽聽聽聽聽聽 |聽 鐩稿浜 GMT 鐨 RFC 822 鏍煎紡鐨勬暟瀛楁椂鍖哄亸绉婚噺锛屼緥濡 -0800銆偮
聽 * ‘Z’聽聽聽聽聽聽聽 聽|聽 琛ㄧず鏃跺尯缂╁啓褰㈠紡鐨勫瓧绗︿覆銆侳ormatter 鐨勮瑷鐜灏嗗彇浠e弬鏁扮殑璇█鐜锛堝鏋滄湁锛夈偮
聽 * ‘s’聽 聽聽聽聽聽聽聽 |聽 鑷崗璋冧笘鐣屾椂 (UTC) 1970 骞 1 鏈 1 鏃 00:00:00 鑷崇幇鍦ㄦ墍缁忚繃鐨勭鏁帮紝鍗 Long.MIN_VALUE/1000 涓 Long.MAX_VALUE/1000 涔嬮棿鐨勫樊鍊笺偮
聽 * ‘Q’聽 聽|聽 鑷崗璋冧笘鐣屾椂 (UTC) 1970 骞 1 鏈 1 鏃 00:00:00 鑷崇幇鍦ㄦ墍缁忚繃鐨勬绉掓暟锛屽嵆 Long.MIN_VALUE 涓 Long.MAX_VALUE 涔嬮棿鐨勫樊鍊笺偮
聽 * ‘B’聽 聽|聽 鐗瑰畾浜庤瑷鐜鐨勬湀浠藉叏绉帮紝渚嬪 鈥淛anuary鈥 鍜 鈥淔ebruary鈥濄偮
聽 * ‘b’聽 聽|聽 鐗瑰畾浜庤瑷鐜鐨勬湀浠界畝绉帮紝渚嬪 鈥淛an鈥 鍜 鈥淔eb鈥濄偮
聽 * ‘h’聽聽 聽|聽涓 ‘b’ 鐩稿悓銆偮
聽 * ‘A’聽 聽|聽 鐗瑰畾浜庤瑷鐜鐨勬槦鏈熷嚑鍏ㄧО锛屼緥濡 鈥淪unday鈥 鍜 鈥淢onday鈥澛
聽 * ‘a’聽 聽|聽 鐗瑰畾浜庤瑷鐜鐨勬槦鏈熷嚑绠绉帮紝渚嬪 鈥淪un鈥 鍜 鈥淢on鈥澛
聽 * ‘C’聽聽 聽|聽闄や互 100 鐨勫洓浣嶆暟琛ㄧず鐨勫勾浠斤紝琚牸寮忓寲涓哄繀瑕佹椂甯﹀墠瀵奸浂鐨勪袱浣嶆暟锛屽嵆 00 – 99聽
聽 * ‘Y’聽 聽|聽 骞翠唤锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑鍥涗綅鏁帮紙鑷冲皯锛夛紝渚嬪锛0092 绛変簬鏍奸噷楂樺埄鍘嗙殑 92 CE銆偮
聽 * ‘y’聽 聽|聽 骞翠唤鐨勬渶鍚庝袱浣嶆暟锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涓や綅鏁帮紝鍗 00 – 99銆偮
聽 * ‘j’聽 聽|聽 涓骞翠腑鐨勫ぉ鏁帮紝琚牸寮忓寲涓哄繀瑕佹椂甯﹀墠瀵奸浂鐨勪笁浣嶆暟锛屼緥濡傦紝瀵逛簬鏍奸噷楂樺埄鍘嗘槸 001 – 366銆偮
聽 * ‘m’聽聽 聽|聽鏈堜唤锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆剁殑涓や綅鏁帮紝鍗 01 – 13銆偮
聽 * ‘d’聽 聽|聽 涓涓湀涓殑澶╂暟锛岃鏍煎紡鍖栦负蹇呰鏃跺甫鍓嶅闆朵袱浣嶆暟锛屽嵆 01 – 31聽
聽 * ‘e’聽聽 聽|聽涓涓湀涓殑澶╂暟锛岃鏍煎紡鍖栦负涓や綅鏁帮紝鍗 1 – 31銆偮
聽 *
聽 **/

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