锘??xml version="1.0" encoding="utf-8" standalone="yes"?>中文字幕亚洲天堂,91亚洲精品麻豆,无码天堂va亚洲va在线vahttp://www.tkk7.com/Good-Game/category/24788.htmlzh-cnWed, 05 Sep 2007 10:05:14 GMTWed, 05 Sep 2007 10:05:14 GMT60jxpath 瀛︿範(fàn)絎旇http://www.tkk7.com/Good-Game/archive/2007/08/13/136318.htmlG_GG_GMon, 13 Aug 2007 02:58:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/08/13/136318.htmlhttp://www.tkk7.com/Good-Game/comments/136318.htmlhttp://www.tkk7.com/Good-Game/archive/2007/08/13/136318.html#Feedback1http://www.tkk7.com/Good-Game/comments/commentRss/136318.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/136318.htmlhttp://commons.apache.org/聽 鐨?jxpath

綾葷殑鍔犺澆
JXPathContext聽context聽=聽JXPathContext.newContext( obj );
//鍜?xpath 鐨?鑼冨洿紜畾

涓鑸彇鍊?瀛樺?
String聽fName聽=聽(String)context.getValue("firstName"); //setValue
//鍙傝?http://www.tkk7.com/Good-Game/archive/2007/08/10/135739.html

涓鑸殑緇熻鍜屼嬌鐢? c 涓?list [id,name,.....]

聽聽聽聽聽聽聽聽JXPathContext聽context聽=聽JXPathContext.newContext(c);
聽聽聽聽聽聽聽 System.out.println(聽context.getValue(
"count(聽.[name='oo'聽and聽id='1'聽]聽)")聽); //瀵硅薄 name=oo 鍜?id=1鐨勬湁澶氬皯涓?/font>
System.out.println( context.getValue("sum( .[name='oo' and id='1' ]/id )") );//瀵硅薄name=oo鍜宨d=1鐨勬墍鏈塱d鐩稿姞





寰楀埌闆嗗悎
聽Iterator聽threeBooks聽=聽context.iterate("books[position()聽<聽4]");
//xpath 鐨勪綅緗嚱鏁?position 鍏朵粬鍑芥暟鍙傝?http://www.w3.org/TR/xpath
//4 Core Function Library

xpath 浣跨敤
publicclass聽Employee聽{
聽聽聽聽
private聽Map聽addressMap聽=new聽HashMap();
聽聽聽聽{
聽聽聽聽聽聽聽聽addressMap.put(
"home",聽new聽Address());
聽聽聽聽聽聽聽聽addressMap.put(
"office",聽new聽Address());
聽聽聽聽}
聽聽聽聽
public聽Map聽getAddresses(){
聽聽聽聽聽聽聽
return聽addressMap;
聽聽聽聽}
聽聽聽聽
聽}
聽String聽homeZipCode聽
=聽(String)context.聽getValue("addresses[@name='home']/zipCode");
//浣跨敤鐨勬槸 addressMap map 鐨?key = home 鐨凙ddress綾誨睘鎬х殑 zipCode

xml 鍦ㄧ▼搴?涓?xpath 鐨勫垏鍏ョ偣
聽聽聽聽<?xml聽version="1.0"聽?>
聽聽聽聽
<vendor>
聽聽聽聽聽聽
<location聽id="store101">
聽聽聽聽聽聽聽聽
<address>
聽聽聽聽聽聽聽聽聽聽
<street>Orchard聽Road</street>
聽聽聽聽聽聽聽聽
</address>
聽聽聽聽聽聽
</location>

聽聽聽聽聽聽
<location聽id="store102">
聽聽聽聽聽聽聽聽
<address>
聽聽聽聽聽聽聽聽聽聽
<street>Tangerine聽Drive</street>
聽聽聽聽聽聽聽聽
</address>
聽聽聽聽聽聽
</location>
聽聽聽聽
</vendor>

class聽Company聽{
聽聽聽聽
private聽Container聽locations聽=null;

聽聽聽聽
public聽Container聽getLocations(){
聽聽聽聽聽聽聽聽
if聽(locations聽==null){
聽聽聽聽聽聽聽聽聽聽聽聽URL聽url聽
=聽getClass().getResource("Vendor.xml");
聽聽聽聽聽聽聽聽聽聽聽聽locations聽
=new聽XMLDocumentContainer(url);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return聽locations;
聽聽聽聽}
聽}

聽context聽
=聽JXPathContext.newContext(new聽Company());

聽String聽street聽
=聽(String)context.getValue(
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
"locations/vendor/location[@id聽=聽'store102']//street");
// 綾籆ontainer鐨?灞炴?locations 澶?vendor(xml鍐? .....

寤虹珛 Path宸ュ巶 灝辨槸 鑷畾涔夊瓧絎︿覆 寰楀埌 鑷畾涔夌被
publicclass聽AddressFactory聽extends聽AbstractFactory聽{
聽聽聽聽
publicboolean聽createObject(JXPathContext聽context,聽Pointer聽pointer,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Object聽parent,聽String聽name,聽
int聽index){
聽聽聽聽聽
if聽((parent聽instanceof聽Employee)聽&&聽name.equals("address"){
聽聽聽聽聽聽聽((Employee)parent).setAddress(
new聽Address());
聽聽聽聽聽聽聽
returntrue;
聽聽聽聽聽}
聽聽聽聽聽
returnfalse;
聽聽聽}
聽}

聽JXPathContext聽context聽
=聽JXPathContext.newContext(emp);
聽context.setFactory(
new聽AddressFactory());
聽context.createPath(
"address");
聽context.createPathAndSetValue(
"address/zipCode",聽"90190");
// emp 綾誨氨鏄?createObject鏂規(guī)硶涓殑 Object
//榪愯瑙f瀽鍒?address瀛楃 灝辮繘鍏?if涓?/font>

寤虹珛鍐呭弬
聽JXPathContext聽context聽=聽JXPathContext.newContext(auth);
聽context.getVariables().declareVariable(
"index",聽new聽Integer(2));
 context.setValue("$index", new Integer(3));
聽Book聽secondBook聽=聽(Book)context.getValue("books[$index]");
// $index 涓?3

紜畾鑼冨洿
Pointer聽
JXPathContext聽context聽=聽JXPathContext.newContext(bean);
聽Pointer聽addressPtr聽
=聽context.getPointer("/employees[1]/addresses[2]");
聽JXPathContext聽relativeContext聽
=
聽聽聽聽聽聽聽聽聽聽聽聽聽聽context.getRelativeContext(addressPtr);

聽String聽zipCode聽=聽(String)relativeContext.getValue("zipCode");
//鍙互鐢?xpath 紜畾鑼冨洿 寰堝ソ 鍛靛懙


鏂規(guī)硶鐨勮仈緋誨簲鐢?br />
publicclass聽Formats聽{
聽聽聽聽
publicstatic聽String聽date(Date聽d,聽String聽pattern){
聽聽聽聽聽聽聽聽
returnnew聽SimpleDateFormat(pattern).format(d);
聽聽聽聽}
聽聽聽聽
聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽
聽context.setFunctions(
new聽ClassFunctions(Formats.class,聽"format"));
//鏂規(guī)硶鐨勮緗?format

聽context.getVariables().declareVariable(
"today",聽new聽Date());
聽String聽today聽
=
聽聽聽聽聽(String)context.getValue(
"format:date($today,聽'MM/dd/yyyy')");


蹇?jī)寰楀Q?浠g爜鍙互鍐欐垚浠涔堟牱鍛~ (JXpath)



G_G 2007-08-13 10:58 鍙戣〃璇勮
]]>
Jakarta Commons BeanUtils 瀛︿範(fàn)http://www.tkk7.com/Good-Game/archive/2007/08/10/135739.htmlG_GG_GFri, 10 Aug 2007 02:36:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/08/10/135739.htmlhttp://www.tkk7.com/Good-Game/comments/135739.htmlhttp://www.tkk7.com/Good-Game/archive/2007/08/10/135739.html#Feedback0http://www.tkk7.com/Good-Game/comments/commentRss/135739.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/135739.htmlhttp://www.duduwolf.com/wiki/2007/296.html
聽聽聽聽聽 http://www.chinaitpower.com/A/2005-07-03/150232.html

1)鏅氱殑Bean澶勭悊聽 涓嶇鏄粈涔圫et鍙傛暟涓?涓?( 瀵硅薄鏈韓, 灞炴у悕鎴栧睘鎬у唴浣嶇疆, 鍊?) //list鐨?/font>add鏈夌偣鐗瑰埆
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽 聽聽聽 聽聽聽 聽 Get
鍙傛暟涓?涓?span style="color: rgb(0, 0, 0);">( 瀵硅薄鏈韓, 灞炴у悕鎴栧睘鎬у唴浣嶇疆 )
聽聽
聽聽聽聽聽聽聽聽Employee聽em聽=new聽Employee();聽 //String name; String[] ss;聽 Map map; List list;
聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,
"name","liukaiyi");聽 //String set
聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,
"ss",new聽String[]{"1","2","3"}); //String[] set
聽聽聽聽聽聽聽 聽聽 BeanUtils.setProperty(em,"ss[2]","google");聽 //String[2] set

聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,
"map",new聽HashMap());聽聽 //Map set聽
聽聽聽聽聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,"map(key)","value");聽 //Map.put(Key,Value)
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,
"list",new聽ArrayList(聽Arrays.asList(聽new聽Object[20]聽)聽)); //List鏈夌偣鐗瑰埆
聽聽聽聽聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,"list[0]","list");聽聽聽聽聽聽 //涓嶅彲浠ョ洿鎺ユ坊鍔狅紵錛燂紵
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽BeanUtils.setProperty(em,
"avg","23");聽聽聽聽聽聽 //int set
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽System.out.println(聽BeanUtils.getSimpleProperty(em,
"name")聽);聽聽聽
聽聽聽聽聽聽聽聽System.out.println(聽BeanUtils.getProperty(em,"ss[2]")聽);
聽聽聽聽聽聽聽聽System.out.println(聽BeanUtils.getProperty(em,"map(key)")聽);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽System.out.println(聽BeanUtils.getProperty(em,
"list[0].class")聽);聽 // 鍙栫殑鏄?==list.get(0).getClass()
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽System.out.println(聽BeanUtils.getProperty(em,
"avg")聽);聽

2)鍔ㄦ佸睘鎬?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">//瀹氫箟鍔ㄦ佸睘鎬ч泦
聽DynaProperty[]聽props聽=new聽DynaProperty[]{
聽聽聽聽
new聽DynaProperty("address",聽java.util.Map.class),
聽聽聽聽
new聽DynaProperty("subordinate",聽mypackage.Employee[].class),
聽聽聽聽
new聽DynaProperty("firstName",聽String.class),
聽聽聽聽
new聽DynaProperty("lastName",聽聽String.class)
聽聽聽聽聽聽};
//鍒涘緩鍔ㄦ佺被鏉ヨ瀹氬姩鎬佸睘鎬у?/span>
聽聽聽聽BasicDynaClass聽dynaClass聽=new聽BasicDynaClass("employee",聽null,聽props);
聽聽聽 DynaBean聽employee聽
=聽dynaClass.newInstance();
聽聽聽聽employee.set(
"address",聽new聽HashMap());
聽聽聽聽employee.set(
"subordinate",聽new聽mypackage.Employee[0]);
聽聽聽聽employee.set(
"firstName",聽"Fred");
聽聽聽聽employee.set(
"lastName",聽"Flintstone");

//涔熷彲浠ュ悓涓婁竴鏍?鎻愪緵緇熶竴 鐨凣et Set 榪樻槸 瀛楃鎿嶄綔 ^o^聽 鍝堝搱
聽聽聽 聽聽聽聽 BeanUtils.setProperty(bean,"address",new HashMap());
聽聽聽 聽聽聽 聽聽聽聽 BeanUtils.setProperty(bean,"address(ads1)","姹熻タ");
聽聽聽 聽聽聽 聽BeanUtils.setProperty(bean,"name","liu");
聽聽聽 聽聽聽 聽BeanUtils.setProperty(bean,"subordinate",new String[3]);
聽聽聽 聽聽聽 聽聽聽聽 BeanUtils.setProperty(bean,"subordinate[1]","heha");
聽聽聽 聽聽聽 聽System.out.println(聽 BeanUtils.getProperty(bean,"address(ads1)") );
聽聽聽 聽聽聽 聽System.out.println(聽 BeanUtils.getProperty(bean,"name") );
聽聽聽 聽聽聽 聽System.out.println(聽 BeanUtils.getProperty(bean,"subordinate[1]") );

3錛塉DBC 鎵╁睍
聽Connection聽conn聽=;
聽聽聽聽Statement聽stmt聽
=聽conn.createStatement();
聽聽聽聽ResultSet聽rs聽
=聽stmt.executeQuery
聽聽聽聽(
"select聽accountid,聽name聽from聽customers");
聽聽聽聽Iterator聽rows聽
=聽(new聽ResultSetDynaClass(rs)).iterator();聽 //ResultSetDynaClass(java.sql.ResultSet resultSet)
聽聽聽聽while聽(rows.hasNext())聽{
//鍒╃敤鍔ㄦ乥ean榪涜杈撳嚭
聽聽聽聽DynaBean聽row聽=聽(DynaBean)聽rows.next();聽聽 //榪炲疄浣揃ean閮藉彲浠ヤ笉瑕佷簡(jiǎn)聽
聽聽聽 聽聽聽 BeanUtils.copyProperties( MyBean ,row );聽 //聽 bean<--dynaBean 灝辮繖鏍峰幓寰楀埌鍊?
^o^聽
聽聽聽 聽聽 聽聽 MyBean.get
Accountid();聽 ....聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽}
聽聽聽聽rs.close();
聽聽聽聽stmt.close();

4)HttpServletRequest 鎵╁睍
聽聽聽聽HttpServletRequest聽request聽=;
聽聽聽聽MyBean聽bean聽
=;
聽聽聽聽HashMap聽map聽
=new聽HashMap();
聽聽聽聽Enumeration聽names聽
=聽request.getParameterNames();
聽聽聽聽
while聽(names.hasMoreElements())聽{
聽聽聽聽聽聽String聽name聽
=聽(String)聽names.nextElement();
聽聽聽聽聽聽map.put(name,聽request.getParameterValues(name));
聽聽聽聽}
聽聽聽聽BeanUtils.populate(bean,聽map);
//bean<--map聽 struts濂借薄鏄氨鐢ㄨ繖涓?Form



G_G 2007-08-10 10:36 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲精品视频久久久| 夭天干天天做天天免费看| 亚洲人成色77777在线观看大| 亚洲免费网站观看视频| 精品国产一区二区三区免费看| 亚洲成a人无码亚洲成www牛牛 | 精品亚洲综合久久中文字幕| jizz免费观看视频| 亚洲色精品aⅴ一区区三区| 国产精品免费观看调教网| 亚洲视频日韩视频| 久久久久国色AV免费观看性色| 亚洲欧美日韩自偷自拍| 免费国产高清视频| 中文字幕av免费专区| 亚洲av日韩av激情亚洲| 一个人免费观看在线视频www | 爱情岛论坛免费视频| 久久精品国产亚洲麻豆| 天天影视色香欲综合免费| 国产成人亚洲综合一区| 可以免费观看的一级毛片| a毛片久久免费观看| 亚洲成a人片在线网站| 麻豆精品国产免费观看| 久久性生大片免费观看性| 亚洲日本va午夜中文字幕一区| 国产一卡2卡3卡4卡无卡免费视频| 亚洲AV无码国产剧情| 亚洲色婷婷综合久久| 久久久www成人免费毛片| 成人a毛片视频免费看| 亚洲综合婷婷久久| 国产午夜免费福利红片| 久久免费看少妇高潮V片特黄| 亚洲最大的黄色网| 中文字幕人成人乱码亚洲电影| 在线观看免费中文视频| 免费人成视频在线播放| 亚洲国产精品无码久久久| 在线亚洲精品自拍|