锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品久久久久久亚洲,国产亚洲av片在线观看播放,久久精品国产亚洲av影院http://www.tkk7.com/lvq810/category/31963.html涓栭棿鏈鍙吹鐨勫氨鏄滀粖鈥濓紝鏈鏄撲撫澶卞緱涔熸槸鈥滀粖鈥濄傚洜涓哄畠鏈瀹規槗涓уけ錛屾墍浠ユ洿瑙夊緱瀹冨疂璐點?/description>zh-cnThu, 21 May 2009 09:13:15 GMTThu, 21 May 2009 09:13:15 GMT60浣跨敤Dom4j鍜寈Path瑙f瀽XML(浜?http://www.tkk7.com/lvq810/articles/271423.htmllvq810lvq810Mon, 18 May 2009 16:12:00 GMThttp://www.tkk7.com/lvq810/articles/271423.html
String xmlName = path + "/" + userName + ".xml";   
        
// 瀹氫箟闇瑕佽繑鍥炵殑絎竴綰ц彍鍗曠殑鍚嶅瓧闆嗗悎   
        List firstNames = new ArrayList();   
        
// Attribute鐨勫睘鎬ч泦鍚?nbsp;  
        List attrs = new ArrayList();   
        
// 澹版槑SAXReader   
        SAXReader saxReader = new SAXReader();   
        
try {   
            Document doc 
= saxReader.read(xmlName);   
            
// 鑾峰緱鎵鏈塯rade=1鐨凟lement鐨則ext鐨勫?nbsp;  
            String xpath = "/tree/item";   
            List list 
= doc.selectNodes(xpath);   
            Iterator it 
= list.iterator();   
            
while (it.hasNext()) {   
                Element elt 
= (Element) it.next();   
                Attribute attr 
= elt.attribute("grade");   
                System.out.println(attr.getValue());   
                
if (new Integer(attr.getValue()).intValue() == 1) {   
                    attr 
= elt.attribute("text");   
                    attrs.add(attr.getValue());   
                    System.out.println(attr.getValue());   
                }   
            }   
  
        } 
catch (DocumentException e) {   
            e.printStackTrace();   
        }   
        
return attrs;  

String xmlName 
= path + "/" + userName + ".xml"
// 瀹氫箟闇瑕佽繑鍥炵殑絎竴綰ц彍鍗曠殑鍚嶅瓧闆嗗悎 
List firstNames = new ArrayList(); 
// Attribute鐨勫睘鎬ч泦鍚?nbsp;
List attrs = new ArrayList(); 
// 澹版槑SAXReader 
SAXReader saxReader = new SAXReader(); 
try { 
Document doc 
= saxReader.read(xmlName); 
// 鑾峰緱鎵鏈塯rade=1鐨凟lement鐨則ext鐨勫?nbsp;
String xpath = "/tree/item"
List list 
= doc.selectNodes(xpath); 
Iterator it 
= list.iterator(); 
while (it.hasNext()) { 
Element elt 
= (Element) it.next(); 
Attribute attr 
= elt.attribute("grade"); 
System.out.println(attr.getValue()); 
if (new Integer(attr.getValue()).intValue() == 1) { 
attr 
= elt.attribute("text"); 
attrs.add(attr.getValue()); 
System.out.println(attr.getValue()); 



catch (DocumentException e) { 
e.printStackTrace(); 

return attrs;

榪樻湁涓涓槸鑾峰彇鏌愪釜鑺傜偣涓嬮潰閲岀殑鎵鏈夌涓綰у瓙鑺傜偣,鑰屼笉鏄墍鏈夌殑鑺傜偣(鍖呮嫭瀛愯妭鐐瑰拰瀛欒妭鐐?.
public static List getSecondMenuNames(String textName, String path,   
            String userName) {   
        String xmlName 
= path + "/" + userName + ".xml";   
        String name 
= textName;   
        
// 瀹氫箟闇瑕佽繑鍥炵殑絎簩綰ц彍鍗曠殑鍚嶅瓧闆嗗悎   
        List firstNames = new ArrayList();   
        
// Attribute鐨勫睘鎬ч泦鍚?nbsp;  
        List attrs = new ArrayList();   
        
// 澹版槑SAXReader   
        SAXReader saxReader = new SAXReader();   
        
try {   
            Document doc 
= saxReader.read(xmlName);   
      
// 榪欎釜xpath鐨勬剰鎬濇槸,鑾峰彇text='緋葷粺綆$悊'鐨勪竴涓狪tem涓嬬殑鎵鏈塈tem鐨勮妭鐐?nbsp;  
            String xpath = "//item[@text='" + name + "']/child::*";   
  
            List list 
= doc.selectNodes(xpath);   
            Iterator it 
= list.iterator();   
            
while (it.hasNext()) {   
                Element elt 
= (Element) it.next();   
  
                Attribute attr 
= elt.attribute("grade");   
                System.out.println(attr.getValue());   
  
                attr 
= elt.attribute("text");   
                System.out.println(attr.getValue());   
                attrs.add(attr.getValue());   
            }   
        } 
catch (Exception e) {   
            e.printStackTrace();   
        }   
        
return attrs;   
    }  

public static List getSecondMenuNames(String textName, String path, 
String userName) { 
String xmlName 
= path + "/" + userName + ".xml"
String name 
= textName; 
// 瀹氫箟闇瑕佽繑鍥炵殑絎簩綰ц彍鍗曠殑鍚嶅瓧闆嗗悎 
List firstNames = new ArrayList(); 
// Attribute鐨勫睘鎬ч泦鍚?nbsp;
List attrs = new ArrayList(); 
// 澹版槑SAXReader 
SAXReader saxReader = new SAXReader(); 
try { 
Document doc 
= saxReader.read(xmlName); 
// 榪欎釜xpath鐨勬剰鎬濇槸,鑾峰彇text='緋葷粺綆$悊'鐨勪竴涓狪tem涓嬬殑鎵鏈塈tem鐨勮妭鐐?nbsp;
String xpath = "//item[@text='" + name + "']/child::*"

List list 
= doc.selectNodes(xpath); 
Iterator it 
= list.iterator(); 
while (it.hasNext()) { 
Element elt 
= (Element) it.next(); 

Attribute attr 
= elt.attribute("grade"); 
System.out.println(attr.getValue()); 

attr 
= elt.attribute("text"); 
System.out.println(attr.getValue()); 
attrs.add(attr.getValue()); 

catch (Exception e) { 
e.printStackTrace(); 

return attrs; 
}

娉ㄦ剰鐪嬪叾涓殑xpath鐨勫啓娉?姝f槸鍥犱負鏈変簡xpath,鎴戜滑鎵嶈兘濡傛綆鍗曠伒媧葷殑瀵箈ml榪涜鎿嶄綔.
鍒氬垰浣跨敤xpath鐨勬椂鍊欏彲鑳戒細鎶ヤ竴涓敊璇?Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
榪欐椂鎴戜滑搴旇寰CLASSPATH瀵煎叆涓涓猨ar鍖?鍙玧axen-1.1.1.jar,鍙粠緗戜笂涓嬭澆.

<?xml version="1.0" encoding="ISO-8859-1"?> 
<bookstore> 
<book> 
  
<title lang="eng">Harry Potter</title> 
  
<price>29.99</price> 
</book> 
<book> 
  
<title lang="eng">Learning XML</title> 
  
<price>39.95</price> 
</book> 
</bookstore>

琛ㄨ揪寮?nbsp;                       鎻忚堪
鑺傜偣鍚?nbsp;                  閫夋嫨鎵鏈夎鍚嶇О鐨勮妭鐐歸泦
/                        閫夋嫨鏍硅妭鐐?br /> //                       閫夋嫨褰撳墠鑺傜偣涓嬬殑鎵鏈夎妭鐐?br /> .                        閫夋嫨褰撳墠鑺傜偣
..                       閫夋嫨鐖惰妭鐐?br /> @                        閫夋嫨灞炴?br /> 紺轟緥
琛ㄨ揪寮?nbsp;                       鎻忚堪
bookstore                閫夋嫨鎵鏈塨ookstore瀛愯妭鐐?br /> /bookstore               閫夋嫨鏍硅妭鐐筨ookstore
bookstore/book           鍦╞ookstore鐨勫瓙鑺傜偣涓夋嫨鎵鏈夊悕涓篵ook鐨勮妭鐐?br /> //book                   閫夋嫨xml鏂囨。涓墍鏈夊悕涓篵ook鐨勮妭鐐?br /> bookstore//book          閫夋嫨鑺傜偣bookstore涓嬬殑鎵鏈夊悕涓篵ook涓鴻妭鐐?br /> //@lang                  閫夋嫨鎵鏈夊悕涓簂ang鐨勫睘鎬?br />
琛ㄨ揪寮?nbsp;                                 鎻忚堪
/bookstore/book[1]                 閫夋嫨鏍瑰厓绱燽ookstore鐨刡ook瀛愬厓绱犱腑鐨勭涓涓?娉ㄦ剰: IE5浠ヤ笂嫻忚鍣ㄤ腑絎竴涓厓绱犳槸0)
/bookstore/book[last()]            閫夋嫨鏍瑰厓绱燽ookstore鐨刡ook瀛愬厓绱犱腑鐨勬渶鍚庝竴涓?br /> /bookstore/book[last()-1]          閫夋嫨鏍瑰厓绱燽ookstore鐨刡ook瀛愬厓绱犱腑鐨勬渶鍚庣浜屼釜
/bookstore/book[position()35.00]   閫夋嫨鏍瑰厓绱燽ookstore鐨刡ook瀛愬厓绱犱腑閭d簺鎷ユ湁price瀛愬厓绱犱笖鍊煎ぇ浜?5鐨?br /> /bookstore/book[price>35.00]/title 閫夋嫨鏍瑰厓绱燽ookstore鐨刡ook瀛愬厓绱犱腑閭d簺鎷ユ湁price瀛愬厓绱犱笖鍊煎ぇ浜?5鐨則itle瀛愬厓绱?br />
閫氶厤絎?nbsp;                       鎻忚堪
*                        鍖歸厤鎵鏈夊厓绱?br /> @*                       鍖歸厤鎵鏈夊睘鎬ц妭鐐?br /> node()                   鍖歸厤浠諱綍綾誨瀷鐨勮妭鐐?br /> 紺轟緥
琛ㄨ揪寮?nbsp;                       鎻忚堪
/bookstore/*             閫夋嫨鏍瑰厓绱燽ookstore鐨勪笅鐨勬墍鏈夊瓙鍏冪礌
//*                      閫夋嫨鏂囨。涓墍鏈夊厓绱?br /> //title[@*]              閫夋嫨鎵鏈夋嫢鏈夊睘鎬х殑title鍏冪礌


lvq810 2009-05-19 00:12 鍙戣〃璇勮
]]>
浣跨敤Dom4j鍜寈Path瑙f瀽XML(涓)http://www.tkk7.com/lvq810/articles/271416.htmllvq810lvq810Mon, 18 May 2009 15:45:00 GMThttp://www.tkk7.com/lvq810/articles/271416.html
<?xml version="1.0" encoding="UTF-8"?>
<books>
    
<!--This is a test for dom4j, jakoes, 2007.7.19-->
    
<book show="yes" url="lucene.net">
        
<title id="456">Lucene Studing</title>
    
</book>
    
<book show="yes" url="dom4j.com">
        
<title id="123">Dom4j Tutorials</title>
    
</book>
    
<book show="no" url="spring.org">
        
<title id="789">Spring in Action</title>
    
</book>
    
<owner>O'Reilly</owner>
</books>

涓嬮潰鎴戜滑浣跨敤dom4j鐨剎Path鏉ヨВ鏋愶細
public void parseBooks(){   
          
        SAXReader reader 
= new SAXReader();   
        
try {   
            Document doc 
= reader.read("books.xml");   
            Node root 
= doc.selectSingleNode("/books");   
            List list 
= root.selectNodes("book[@url='dom4j.com']");   
              
            
for(Object o:list){   
                  
                Element e 
= (Element) o;   
                String show
=e.attributeValue("show");   
                System.out.println(
"show = " + show);   
            }   
             
        } 
catch (Exception e) {   
            e.printStackTrace();   
        }   
    }  

public void parseBooks(){
       
        SAXReader reader 
= new SAXReader();
        
try {
            Document doc 
= reader.read("books.xml");
            Node root 
= doc.selectSingleNode("/books");
            List list 
= root.selectNodes("book[@url='dom4j.com']");
           
            
for(Object o:list){
               
                Element e 
= (Element) o;
                String show
=e.attributeValue("show");
                System.out.println(
"show = " + show);
            }
          
        } 
catch (Exception e) {
            e.printStackTrace();
        }
    }
 

Document doc = reader.read("books.xml");鐨勬剰鎬濇槸鍔犺澆XML鏂囨。錛屾鏄彲浠ョ敤
doc.asXML()鏉ユ煡鐪嬶紝瀹冨皢鎵撳嵃鏁翠釜xml鏂囨。銆?

Node root = doc.selectSingleNode("/books");鏄鍙栧垰鎵嶅姞杞界殑xml鏂囨。鍐呯殑books鑺傜偣涓嬬殑鎵鏈夊唴瀹癸紝瀵逛簬鏈緥涔熸槸鏁翠釜xml鏂囨。銆?
褰撶劧鎴戜滑涔熷彲浠ュ姞杞?books涓嬬殑鏌愪竴涓妭鐐癸紝濡傦細book鑺傜偣
Node root = doc.selectSingleNode("/books/book");
鎴栵細Node root = doc.selectSingleNode("/books/*");
娉ㄦ剰錛氬鏋滄湁澶氫釜book鑺傜偣錛屽畠鍙細璇誨彇絎竴涓?
root.asXML()灝嗘墦鍗幫細
<book show="yes" url="lucene.net">
    <title id="456">Lucene Studing</title>
</book>

鏃㈢劧鍔犺澆浜嗚繖涔堝錛岄偅鎴戞庝箞綺劇‘鐨勫緱鍒版垜鎯寵鐨勮妭鐐瑰憿錛屽埆鎬ワ紝鐪嬩笅闈細
List list = root.selectNodes("book[@url='dom4j.com']");
瀹冪殑鎰忔濆氨鏄鍙朾ooks鑺傜偣涓嬬殑book鑺傜偣錛屼笖book鐨勮妭鐐圭殑url灞炴т負dom4j.com
涓轟粈涔堜嬌鐢╨ist鏉ユ帴鏀跺憿錛屽鏋滄湁涓や釜book鑺傜偣錛屼笖瀹冧滑鐨剈rl灞炴ч兘涓篸om4j.com錛屾鏃跺氨灝侀棴鍒發ist閲屼簡銆?

濡傛灉鎯寵鍙朾ooks涓嬬殑鎵鏈塨ook鑺傜偣錛屽彲浠ヨ繖鏍鳳細
List list = root.selectNodes("book");

濡傛灉鎯寵鍙朾ooks鑺傜偣涓嬬殑book鑺傜偣涓嬬殑title鑺傜偣錛屽彲浠ヨ繖鏍鳳細
List list2 = root.selectNodes("book[@url='dom4j.com']/title[@id='123']");

娉ㄦ剰錛歴electNodes()鍙傛暟鐨勬牸寮忥細
鑺傜偣鍚峓@灞炴у悕='灞炴у?]錛屽錛歜ook[@url='dom4j.com']
濡傛灉鏈夊涓妭鐐癸紝鐢?#8220;/”鍒嗗紑錛屽錛歜ook[@url='dom4j.com']/title[@id='123']

鏈榪戝氨鏄鍙栧皝闂湪List閲岀殑鍐呭浜嗭紝鍙互鐢∟ode鏉ヨ鍙栵紝涔熷彲浠ョ敤Element鏉ヨ漿鎹€?
attributeValue("灞炴?)鏄鍙栬鑺傜偣鐨勫睘鎬у?
getText()鏄鍙栬妭鐐圭殑鐨勫唴瀹廣?br />
selectNodes(Object context, XPath sortXPath)絎簩涓弬鏁扮敤鏉ヨ緗帓搴忕殑灞炴у悕
濡傦細List list = root.selectNodes("book/title","@id");
榪欐牱鍒欎細鏍規嵁title鑺傜偣鐨刬d灞炴ф帓搴?

lvq810 2009-05-18 23:45 鍙戣〃璇勮
]]>
110涓煡鍚岼ava欏圭洰闆嗛敠 http://www.tkk7.com/lvq810/articles/227026.htmllvq810lvq810Thu, 04 Sep 2008 09:37:00 GMThttp://www.tkk7.com/lvq810/articles/227026.htmlhttp://www.tkk7.com/lvq810/comments/227026.htmlhttp://www.tkk7.com/lvq810/articles/227026.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/227026.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/227026.html
欏圭洰鍚嶇О   欏圭洰鎻忚堪
ASM Java bytecode manipulation framework
AspectWerkz AspectWerkz - Dynamic AOP for Java
Axis Axis - an implementation of the SOAP (Simple Object Access Protocol) submission to W3C
Batik Batik SVG Toolkit - Toolkit using images in the Scalable Vector Graphics (SVG) format
BCEL Byte Code Engineering Library - Analyze, create and manipulate Java class files
BeanUtils BeanUtils - Utilities for working with JavaBeans
Catalina Catalina - Servlet and JSP based web server
Cayenne Professional Object Relational Mapping
CGLIB CGLIB - Dynamic byte code generatorhttp://andyluo.blogjava.net
Chain Chain - Implementation of the GoF "Chain of Responsibility" pattern
Checkstyle Checkstyle - Development tool to help writing Java code that adheres to a coding standard
CLI Command Line Library - Simple API for working with the command line arguments and options
Codec Commons Codec - Encoders and decoders like Base64, Hex, phonetic encodings and URLs
Collections Collections - Filling the holes left in Sun's Collections API
Configuration Commons Configuration - Generic API enabling configuration from a variety of sources
DBCP DBCP - Connection pooling implementations
DBUtils DbUtils - Set of classes designed to make working with JDBC easier
Digester Struts Digester - Configure an XML/Java mapping with actions when patterns are recognized
Discovery Discovery - Discovering, or finding, implementations for pluggable interfaces
DNSJava DNS in Java - Supporting common record types, queries, zone transfers and dynamic updates
doclet JavaDoc Doclet - Custom output from the types methods and fields in a source tree.
Dom4j DOM4J - XML, XPath and XSLT library
DTDParser DTDParse DTD Library - You can use this library to parse a DTD
EL EL - The JSP 2.0 Expression Language Interpreter from Apache
fastutil FastUtil - Type-specific maps sets and lists with a small memory footprint and fast access
FileUpload HTTP File Upload Library - Add robust, fast file upload capability to your web applications
FreeMarker HTML Template Enginehttp://andyluo.blogjava.net
GJT Giant Java Tree - Java library consisting entirely of open source components
gnu-regex GNU Regular Expressions - Implementation of a traditional (non-POSIX) NFA regex engine
Groovy Groovy - Scripting Language
Hibernate Hibernate - Relational Persistence For Idiomatic Java
HiveMind HiveMind - A services and configuration microkernel
HSQLDB HSQLDB - The Java SQL relational database
HTMLParser HTML Parser - Java library used to parse HTML
HTTPClient HTTP Client - Fills holes left by the java.net package, including most recent HTTP standards
Informa Informa - News aggregation library
IO Commons-IO - Utility classes, stream implementations, file filters and endian classes for IO
iText iText - Generates PDF o­n the fly
J2EE Java 2 Platform, Enterprise Edition
J2SE Java2 Standard Edition v5
JAI Java Advanced Imaging - Network-enabled, scalable, platform-independent image processing
Jalopy Jalopy Source Formatter - Formats Java source code according to widely configurable rules
Jasper Jasper - Tomcat JSP enginehttp://andyluo.blogjava.net
JasperReports JasperReports - Free Java reporting library
Java3d Java3D - Object-oriented interfaces that support a simple, high-level programming mode
JavaComm Java Communications - API for technologies such as voice mail, fax and smartcards
JavaGroups JavaGroups - Reliable multicast communication enable processes to send messages to each other
Jaxen Jaxen XPath Processor - Object model walker; evaluate XPath expressions in dom4j and JDOM
JAXME JaxMe 2 - Open source implementation of JAXB
JClassLib JClassLib - Library for reading, modifing and writing Java class files and bytecode
JCommon JCommon - Collection of useful classes used by JFreeChart, JFreeReport and other projects
JCrontab JCronTab - Scheduler written in Java, provide a fully functional schedules for Java projects
JDIC JDIC - JDesktop Integration Components
JDNC JDNC - JDesktop Network Components
JDO Java Data Objects - Direct storage of Java domain model instances into a database
JDOM JDOM XML Library - For accessing, manipulating and outputting XML data from Java code.
JetSpeed JetSpeed - Java Portal Server
JEXL Java Expression Language - is an embedable expression language engine
JFreeChart JFreeChart - Free library for generating charts, including pie, bar, line and areas charts
JGroups JGroups - Multicast communication toolkit
JMeter JMeter - Load testing applcation
JMF Java Media Framework - Library for audio, video and other time-based media
JMock JMock - Testing library
JSF JavaServer Faces - Web Framework
JSword JSword - Bible software in Java, compatible with the Sword project for C/C++
JTidy JTidy - HTML syntax checker
JUnit JUnit - Regression testing framework used by the developer who implements unit tests in Java
JXPath JXPath Library - Simple interpreter of an expression language called XPath
Lang Lang - Utilities including Enums, String manipulation, reflection, serialization and more
Log4J Log4J - Fast logging API that lets you configure logging at runtime
Logging Commons Logging - Simple wrapper API around multiple logging APIs
Lucene Lucene - high-performance, full-featured text search engine written entirely in Java
Math Math - Library of lightweight, self-contained mathematics and statistics components
Net Network Library - Support for Finger, Whois, TFTP, Telnet, FTP, NNTP, etc developed by ORO
OJB OJB - O/R tool that allows transparent persistence
OpenJMS Open source JMS server
ORO ORO - Text processing library
OSCache OSCache - A high performance J2EE caching framework
PJA Pure Java AWT - Toolkit for drawing graphics without any native graphics resources
PMD PMD - Scans Java source code for potential problems
POI POI - Java OLE 2 Manipulator
Pool Commons Pooling - provides an generic, configurable Object-pooling API
Primitives Primitives - Collection of types and utilities optimized for working with Java primitives
Proxool Java connection pool
Quartz Quartz - J2EE open source job scheduler
Regexp Jakarta Regular Expressions - Java RegEx library under BSD style license
Rhino Mozilla JavaScript - open-source implementation of JavaScript written entirely in Java
Seraph Seraph - Atlassian Security Framework
SiteMesh A web-page layout and decoration framework
Slide Slide - Content repository, can serve as a basis for CMS
SOAP Apache Soap - implementation of the SOAP submission to W3C
Speedo OSS JDO implementationhttp://andyluo.blogjava.net
Spring Server Side alternative to J2EE APIs
Struts Jakarta Struts - open source framework for building web applications
Tapestry Tapestry - Web Framework
Turbine Turbine - Servlet based framework allowing developers to quickly build secure web applications
UDDI4J UDDI4J - Library that provides an API to interact with a UDDI registry
Validator Validtator - Validate data from user input
Velocity Velocity - Support for clean, quick MVC web development and support for the Struts framework
Village Village - API that sits o­n top of the JDBC to make it easier to interact with a JDBC
WebWork 2 Next generation of WebWork
Xalan Xalan - XSLT processor for transforming XML documents into HTML, text, or XML
XDoclet XDoclet - Code generation engine
Xerces Xerces2 - The next generation of high performance, XML parsers in the Apache Xerces family
XMLBeans XMLBeans - XML-Java binding toolhttp://andyluo.blogjava.net
XMLPull XMLPull - Defines a simple pull parsing API that does pull XML parsing from J2ME to J2EE
XMLRPC XML-RPC - Implementation of XML-RPC, using XML over HTTP to implement remote procedure calls
XNI Xerces Native Interface - Framework for streaming a document and constructing generic parsers
XOM XML Object Model - Tree-based API for processing XML that strives for correctness and simplicity.
XStream XML serialization


lvq810 2008-09-04 17:37 鍙戣〃璇勮
]]>
struts validwhen鐨勪嬌鐢?/title><link>http://www.tkk7.com/lvq810/articles/226972.html</link><dc:creator>lvq810</dc:creator><author>lvq810</author><pubDate>Thu, 04 Sep 2008 07:25:00 GMT</pubDate><guid>http://www.tkk7.com/lvq810/articles/226972.html</guid><wfw:comment>http://www.tkk7.com/lvq810/comments/226972.html</wfw:comment><comments>http://www.tkk7.com/lvq810/articles/226972.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/lvq810/comments/commentRss/226972.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/lvq810/services/trackbacks/226972.html</trackback:ping><description><![CDATA[<div style="font-size: 10pt;"> <p>validwhen涓昏鐢ㄤ簬鍏寵仈楠岃瘉錛屽嵆涓轟簡楠岃瘉鏌愪釜鍩熺殑鍊鹼紝鍙兘浼氬弬鑰冨叾瀹冨煙鐨勫兼潵榪涜緇煎悎鍒ゆ柇錛屼互紜畾璇ュ煙鐨勫兼槸鍚︾鍚堣姹傘?/p> <p>1錛岃〃杈懼紡鍙婂叾娉ㄦ剰浜嬮」</p> <p>杈撳叆緇檝alidwhen鐨勬槸涓涓竷灝斿瀷琛ㄨ揪寮忥紙瀵硅琛ㄨ揪寮忕殑瑙f瀽浣跨敤浜哸ntlr錛夛紝鍏跺紩鐢ㄥ悕涓簍est錛屽嵆褰㈠錛?/p> <p><var><br />   <var-name>test</var-name><br />   <var-value>expression</var-name><br /> </var></p> <p>鍗籌紝褰揺xpression涓虹湡(true)鏃訛紝璇ュ煙楠岃瘉閫氳繃錛屽叾涓紝expression鍙互浣跨敤鐨勫厓绱犲寘鎷細</p> <p>1錛夎〃鍗曚腑鍏跺畠鍩熷睘鎬х殑鍚嶇О錛屼緥濡傦細<br /> <var><br />   <var-name>test</var-name><br />   <var-value>(color=="red")</var-name><br /> </var> <br /> 渚嬪瓙涓璫olor涓鴻〃鍗曚腑鍏跺畠鏌愪釜鍩熺殑灞炴у悕銆?/p> <p>2錛?this*錛岀敤浜庤〃紺鴻鍩熺殑灞炴у悕縐幫紝鍗沖姝e湪楠岃瘉鐨勫睘鎬ц嚜韜紝鍏跺彉閲忕殑寮曠敤涓?this*錛屼緥濡傦細<br /> <var><br />   <var-name>test</var-name><br />   <var-value>((color=="red") and (*this* != null))</var-name><br /> </var> </p> <p>3錛夊彲浠ヤ嬌鐢ㄤ竴浜涘父瑙勮繍綆楃錛屽 >銆?lt;銆?=銆?gt;=銆?lt;=銆?=銆?銆?銆?銆?銆?絳夌瓑銆備緥濡傦細<br /> <var><br />   <var-name>test</var-name><br />   <var-value>((color=="red") and (age>=25))</var-name><br /> </var> </p> <p>4錛夊彲浠ヤ嬌鐢ㄩ昏緫榪愮畻 and 銆乷r錛屼緥濡傦細<br /> <var><br />   <var-name>test</var-name><br />   <var-value>(((color=="red") and (age>=25)) or (color!="red"))</var-name><br /> </var> <br /> 鍦ㄤ嬌鐢╝nd鍜宱r鏃惰娉ㄦ剰涓鐐癸紝鍦ㄥ悓涓綰х殑閫昏緫榪愮畻涓紝鍚屾椂鍙兘瀛樺湪涓涓昏緫榪愮畻絎︼紝瑕佷箞鏄痑nd錛岃涔堟槸or錛屽嵆錛?br /> xxx and yyy<br /> 鎴栬?br /> xxx or yyy<br /> 濡傛灉鍦ㄥ悓涓綰у嚭鐜板浜庝竴涓殑and鎴杘r鎴朼nd鍜宱r鐨勭粍鍚堬紝閭d箞鏄笉鍚堟硶鐨勶紝渚嬪涓嬮潰鐨勮〃杈懼紡鏄笉鍚堟硶鐨勶細<br /> xxx and yyy and zzz<br /> 鎴栬?br /> xxx or yyy or zzz<br /> 鎴栬?br /> xxx and yyy or zzz<br /> 絳夌瓑<br /> 涓轟簡璁╁鏉傜殑琛ㄨ揪鍙樺緱鍚堟硶錛屽彲浠ヨ涓涓鏉傜殑琛ㄨ揪寮忓彉涓哄綰х殑琛ㄨ揪褰㈠紡錛屾瘡涓綰у彧鏈変竴涓猘nd鎴栦竴涓猳r灝卞彲浠ヤ簡錛屼緥濡傦細<br /> xxx and yyy and zzz鏄敊璇殑錛岃繘琛屼竴涓嬬畝鍗曠殑鍙樻崲錛?br /> (xxx and yyy) and zzz鎴栬厁xx and (yyy and zzz)絳夐兘鏄悎娉曠殑銆?/p> <p>5錛夊叾浠栧悎娉曠殑杈撳叆錛屼緥濡傚彲浠ヤ嬌鐢ㄥ弻寮曞彿鍜屽崟寮曞彿寮曠敤literal瀛楃涓茬瓑絳夈?/p> <p>2錛岄敊璇秷鎭殑瀹氬埗</p> <p>鏃犺鏄痸alidwhen榪樻槸鍏跺畠楠岃瘉渚嬬▼錛岄兘鍙互瀹氬埗楠岃瘉鍑洪敊鍚庣殑閿欒淇℃伅錛屽畾鍒舵秷鎭湁涓ょ鏂瑰紡錛屽嵆鍏ㄥ眬鏂瑰紡鍜屾湰鍦版柟寮忋?/p> <p>1錛夊叏灞鏂瑰紡錛屽嵆鍦╲alidator-rules.xml涓煇涓獀alidator閲岄潰瀹氫箟鐨勬秷鎭紝鍙傛暟鍚嶄負msg錛屼緥濡傦細<br /> <!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code="--"><!-- = Java2Html Converter V3.6 2003 by Markus Gebhard markus@jave. de="--"><!-- = Further information: http://www.java2html. de="--"></p> <div align="left"> <table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0"> <tbody> <tr> <!-- start source code --> <td align="left" nowrap="nowrap" valign="top"><code><br /> <font color="#000000"><validator name=</font><font color="#2a00ff">"email"</font><br /> <font color="#ffffff">            </font><font color="#000000">classname=</font><font color="#2a00ff">"org.apache.struts.validator.FieldChecks"</font><br /> <font color="#ffffff">               </font><font color="#000000">method=</font><font color="#2a00ff">"validateEmail"</font><br /> <font color="#ffffff">         </font><font color="#000000">methodParams=</font><font color="#2a00ff">"java.lang.Object,</font><br /> <font color="#ffffff">                       </font><font color="#2a00ff">org.apache.commons.validator.ValidatorAction,</font><br /> <font color="#ffffff">                       </font><font color="#2a00ff">org.apache.commons.validator.Field,</font><br /> <font color="#ffffff">                       </font><font color="#2a00ff">org.apache.struts.action.ActionMessages,</font><br /> <font color="#ffffff">                       </font><font color="#2a00ff">org.apache.commons.validator.Validator,</font><br /> <font color="#ffffff">                       </font><font color="#2a00ff">javax.servlet.http.HttpServletRequest"</font><br /> <font color="#ffffff">              </font><font color="#000000">depends=</font><font color="#2a00ff">""</font><br /> <font color="#ffffff">                  </font><font color="#000000">msg=</font><font color="#2a00ff">"errors.email"</font><font color="#000000">/></font></code> </td> <!-- end source code --> </tr> </tbody> </table> </div> <!-- = END of automatically generated HTML code="--"><!-- ======================================================== --> <p>鍏朵腑錛宮sg鐨勫間負resource bundle涓殑涓涓睘鎬у悕</p> 銆備緥濡傚湪resource bundle鏂囦歡涓瓨鍦ㄥ涓嬪畾涔夛細<br /> errors.email={0} is an invalid e-mail address. <p> </p> <p>2錛夋湰鍦版柟寮忥紝鍗沖湪validation.xml涓殑field涓畾涔夌殑閿欒娑堟伅錛屾牸寮忎負錛?br /> <msg key="value" resource="booleanValue"/><br /> 渚嬪錛?br /> <!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code="--"><!-- = Java2Html Converter V3.6 2003 by Markus Gebhard markus@jave. de="--"><!-- = Further information: http://www.java2html. de="--"></p> <div align="left"> <table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0"> <tbody> <tr> <!-- start source code --> <td align="left" nowrap="nowrap" valign="top"><code><font color="#ffffff">             </font><font color="#000000"><field property=</font><font color="#2a00ff">"endDate"</font><br /> <font color="#ffffff">                    </font><font color="#000000">depends=</font><font color="#2a00ff">"validwhen,date"</font><font color="#000000">></font><br /> <font color="#ffffff">                </font><font color="#000000"><msg name=</font><font color="#2a00ff">"validwhen" </font><font color="#000000">key=</font><font color="#2a00ff">"date.validwhen"</font><font color="#000000">/></font><br /> <font color="#ffffff">                </font><font color="#000000"><arg0 key=</font><font color="#2a00ff">"start time" </font><font color="#000000">resource=</font><font color="#2a00ff">"false"</font><font color="#000000">/></font><br /> <font color="#ffffff">                </font><font color="#000000"><arg1 key=</font><font color="#2a00ff">"end time" </font><font color="#000000">resource=</font><font color="#2a00ff">"false"</font><font color="#000000">/></font><br /> <font color="#ffffff">                </font><font color="#000000"><var></font><br /> <font color="#ffffff">                     </font><font color="#000000"><var-name>test</var-name> </font><br /> <font color="#ffffff">                     </font><font color="#000000"><var-value></font><font color="#000000">((</font><font color="#000000">*</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">* != </font><font color="#7f0055"><strong>null</strong></font><font color="#000000">) </font><font color="#000000">and </font><font color="#000000">(</font><font color="#000000">*</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">*>startDate</font><font color="#000000">))</font><font color="#000000"></var-value></font><br /> <font color="#ffffff">                </font><font color="#000000"></var></font><br /> <font color="#ffffff">             </font><font color="#000000"></field></font></code> </td> <!-- end source code --> </tr> </tbody> </table> </div> <!-- = END of automatically generated HTML code="--"><!-- ======================================================== --> <p>榪欓噷闇瑕佹敞鎰忕殑鏄?br /> * <msg>鐨刵ame灞炴х殑鍊煎簲璇ヤ負鏌愪釜楠岃瘉渚嬬▼鐨勫悕縐幫紝渚嬪name="<font color="#2a00ff" face="Courier New">validwhen</font>"銆乶ame="<font color="#2a00ff" face="Courier New">date</font>"絳夛紝榪欐寚鏄庝簡褰撹field鐨勮楠岃瘉渚嬬▼錛堟湰渚嬫槸<font color="#2a00ff" face="Courier New">validwhen</font>銆?font color="#2a00ff" face="Courier New">date</font>錛夊嚭閿欐椂鎵鏄劇ず鐨勯敊璇俊鎭?br /> *濡傛灉鍏ㄥ眬宸茬粡瀹氫箟浜唌sg鐨勪俊鎭紝鑰屼笖鏈湴鐨刴sg鐨刱ey涓庡叏灞鐨刴sg鐨刱ey鐩稿悓錛岄偅涔堝湪璇ield鐨勯獙璇佷腑錛屾湰鍦扮殑msg灝嗚鐩栧叏灞鐨刴sg銆?br /> *<arg0>鍒?lt;arg4>鐨勫睘鎬т腑涔熸湁name灞炴э紝鍗寵arg鍙傛暟鎵搴旂敤鐨勯獙璇佷緥紼嬶紝渚嬪<arg0 key="label.startDate"/>錛屽嵆璇ュ弬鏁扮敤浜巇ate楠岃瘉鐨勫嚭閿欎俊鎭傛敞鎰忥紝瀵逛簬涓涓猣ield錛岄渶瑕佺殑楠岃瘉瑙勫垯鏈夋椂涓嶆涓涓紝渚嬪depends="required,date"錛岃屽涓獙璇佽鍒欎腑鐨勬瘡涓涓兘闇瑕佸嚭閿欐椂浼犲叆涓浜涘弬鏁頒俊鎭紝濡傛灉瀹冧滑鎵闇瑕佺殑鍙傛暟涓暟銆佸悕縐板拰欏哄簭閮界浉鍚岋紝閭d箞鍙瀹氫箟<arg0...銆?lt;arg1...絳夌瓑鍗沖彲銆備絾鏄鏋滃畠浠渶瑕佺殑鍙傛暟鐨勪釜鏁般佸悕縐板拰欏哄簭涓嶅悓鎬庝箞鍔烇紝濡傛灉鎴戜滑瀵逛簬絎竴涓緭鍏ュ弬鏁板彧瀹氫箟涓涓猘rg0錛岄偅涔堣繖涓猘rg0鐢ㄤ簬鍝釜楠岃瘉娑堟伅錛屽洜姝よ繖鏃跺繀欏婚氳繃arg鏍囩鐨刵ame灞炴ф潵琛ㄧず璇ュ弬鏁版墍鏈嶅姟鐨勯獙璇併?/p> <p>3錛屼緥瀛?/p> <p>鍦烘櫙錛氬湪涓涓〃鍗曚腑錛屾湁涓や釜鏂囨湰鍩燂紝鐢ㄤ簬寰楀埌涓涓椂闂存錛屼竴涓枃鏈煙杈撳叆璧峰鏃ユ湡錛坰tartDate錛夛紝鍙︿竴涓緭鍏ョ粓姝㈡棩鏈燂紙endDate錛夈?br /> 綰︽潫錛氭棩鏈熸牸寮忎負錛氬勾錛堝洓浣嶆暟錛?鏈堬紙涓や綅鏁幫級-鏃ワ紙涓や綅鏁幫級錛岃屼笖緇堟鏃ユ湡澶т簬璧峰鏃ユ湡銆?/p> <p>鏍規嵁涓婅堪鏉′歡錛岄獙璇佽鍒欏涓嬶細<br /> <!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code="--"><!-- = Java2Html Converter V3.6 2003 by Markus Gebhard markus@jave. de="--"><!-- = Further information: http://www.java2html. de="--"></p> <div align="left"> <table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0"> <tbody> <tr> <!-- start source code --> <td align="left" nowrap="nowrap" valign="top"><code><font color="#000000"><field property="startDate"</font><br /> <font color="#ffffff">    </font><font color="#000000">depends="date"></font><br /> <font color="#ffffff">    </font><font color="#000000"><arg0 key="form.date.start"/></font><br /> <font color="#ffffff">    </font><font color="#000000"><var></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-name>datePatternStrict</var-name></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-value>yyyy-MM-dd</var-value></font><br /> <font color="#ffffff">    </font><font color="#000000"></var></font><br /> <font color="#000000"></field></font><br /> <font color="#000000"><field property="endDate"</font><br /> <font color="#ffffff">    </font><font color="#000000">depends="validwhen,date"></font><br /> <font color="#ffffff">    </font><font color="#000000"><msg name="validwhen" key="date.validwhen"/></font><br /> <font color="#ffffff">    </font><font color="#000000"><arg0 name="validwhen" key="form.date.start"/></font><br /> <font color="#ffffff">    </font><font color="#000000"><arg1 name="validwhen" key="form.date.end"/></font><br /> <font color="#ffffff">    </font><font color="#000000"><arg0 name="date" key="form.date.end"/></font><br /> <font color="#ffffff">    </font><font color="#000000"><var></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-name>test</var-name></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-value></font><font color="#000000">((</font><font color="#000000">*</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">* != </font><font color="#7f0055"><strong>null</strong></font><font color="#000000">) </font><font color="#000000">and </font><font color="#000000">(</font><font color="#000000">*</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">*>startDate</font><font color="#000000">))</font><font color="#000000"></var-value></font><br /> <font color="#ffffff">    </font><font color="#000000"></var></font><br /> <font color="#ffffff">    </font><font color="#000000"><var></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-name>datePatternStrict</var-name></font><br /> <font color="#ffffff">        </font><font color="#000000"><var-value>yyyy-MM-dd</var-value></font><br /> <font color="#ffffff">    </font><font color="#000000"></var></font><br /> <font color="#000000"></field> </font></code> </td> <!-- end source code --> </tr> </tbody> </table> </div> <!-- = END of automatically generated HTML code="--"><!-- ======================================================== --> <p>鍦ㄨ祫婧愭枃浠朵腑鍔犲叆濡備笅message錛?/p> <p> </p> form.date.start=璧峰鏃ユ湡<br /> form.date.end=緇堟鏃ユ湡<br /> date.validwhen= {0}涓嶈兘澶т簬{1}!</div> <img src ="http://www.tkk7.com/lvq810/aggbug/226972.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/lvq810/" target="_blank">lvq810</a> 2008-09-04 15:25 <a href="http://www.tkk7.com/lvq810/articles/226972.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍏充簬Spring + Hibernate澶勭悊CLOB瀛楁鐨勯棶棰榌杞琞http://www.tkk7.com/lvq810/articles/226966.htmllvq810lvq810Thu, 04 Sep 2008 07:10:00 GMThttp://www.tkk7.com/lvq810/articles/226966.htmlhttp://www.tkk7.com/lvq810/comments/226966.htmlhttp://www.tkk7.com/lvq810/articles/226966.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/226966.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/226966.htmldwr
+spring+hibernate寮鍙戜竴涓皬鐨勪笢涓滐紝鍏墮棿闇瑕佸ORACLE鐨勫ぇ鏁版嵁綾誨瀷CLOB瀛楁榪涜鎻掑叆鎿嶄綔錛屽彂鐜癈LOB瀛楁涓嶅儚涓鑸暟鎹被鍨嬮偅涔堝鐞嗙畝鍗曘傚湪鏌ラ槄浜嗚澶氳祫鏂欏悗錛岀粓浜庢壘鍒頒簡瑙e喅閫旂粡銆傜幇鎶婅В鍐寵繃紼嬭窡澶у鍒嗕韓涓涓嬶細ITPUB涓漢絀洪棿 ^0s:tU9pV M
1.spring閰嶇疆錛?/strong>
QnTq5x`j C0<bean id="nativeJdbcExtractor"
3~NY tl&TvZ0class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"ITPUB涓漢絀洪棿 Sf4pQF}}
  lazy-init="true" />ITPUB涓漢絀洪棿(_T BM E錕絏,xW ES U)B
<bean id="lobHandler"
`z`{[ Q&LSD1H:Np0  class="org.springframework.jdbc.support.lob.OracleLobHandler"ITPUB涓漢絀洪棿 x/C!zyCl_%Q-P
  lazy-init="true">ITPUB涓漢絀洪棿 fshAWJP:Q
  <property name="nativeJdbcExtractor">
L Z_;z4wq錕絶;y0   <ref local="nativeJdbcExtractor" />ITPUB涓漢絀洪棿.Wi_ hcZ.m/F
  </property>ITPUB涓漢絀洪棿(QB:?;^R b
</bean>

y'O錕絞K2D8gKX0
    <!-- Hibernate SessionFactory -->ITPUB涓漢絀洪棿#SRf7K(h^ mA
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">ITPUB涓漢絀洪棿H^7[I6kvB
        <property name="dataSource" ref="dataSource"/>
-}{Yd r hp&U0<property name="lobHandler" ref="lobHandler" />ITPUB涓漢絀洪棿jn }DJ%HH
  <property name="mappingDirectoryLocations">
7@ ns{4\4M%vy-aIF0   <list>ITPUB涓漢絀洪棿yb Z/C*t4r
    <value>classpath:/com/ffcs/crm/models</value>
K m(r X~$BTCF0   </list>ITPUB涓漢絀洪棿i#l8n錕紷#p`
  </property>
$^5Qd_grr$K0        <property name="hibernateProperties">
&vSp2VAZ$E:Q0            <props>
a+X+@7}NT/^O0                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
%g錕絋bx-p4rMc,J3t0                <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
j3Nndu0                <prop key="hibernate.show_sql">true</prop>
E2b;]h@0                <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>ITPUB涓漢絀洪棿h/Ox ~ g,f
            </props>ITPUB涓漢絀洪棿+FT3oj4\
        </property>ITPUB涓漢絀洪棿.FQ z.Rz-k
    </bean>ITPUB涓漢絀洪棿/SZ%R3m*u g]6r
2.Hibernate鏄犲皠鏂囦歡閰嶇疆錛?/strong>ITPUB涓漢絀洪棿/Hn&A ^ ZNY-kX
    <property
+i2|vf+ET)@(Hk0RD8o0        name="content"
7h2s.H }8^;O7T0        type="org.springframework.orm.hibernate3.support.ClobStringType"
PjR?4`N0        column="CONTENT"ITPUB涓漢絀洪棿T$HwP0NWkX
        length="4000"ITPUB涓漢絀洪棿 W錕紷q8ZI
    >ITPUB涓漢絀洪棿*BpN c7X$[ m
3.PO鐨剆eter/geter:
o q I^ih{0private String content;
&[g&p|7S0public String getContent() {
WB F錕統M X8g0  return content;
lYP"E3\0}
%Mm&w)pl ?9P0public void setContent(String content) {ITPUB涓漢絀洪棿X{qqYz+~dr
  this.content = content;ITPUB涓漢絀洪棿lqj-xl%T$}
}ITPUB涓漢絀洪棿5]_'U lt Py7CnV U^
4.鍦╯ervice灞傛垜浠氨鍙互鐩存帴灝哣O鐨刢ontent鐩存帴set榪汸O灝監K錛岃窡涓鑸暟鎹被鍨嬩竴鏍峰鐞嗐?br /> vn7DJ^f錕絚0
.`7n!x8O&J+y#g6p!^f1@0OK浜嗭紒
f_+h h錕絅j#W#y3|#]0鏄笉鏄緢綆鍗曪紵涔嬪墠涓鐩村湪瀵繪壘hibernate 瀵笴LOB鐨勬敮鎸侊紝璇曡繃寰堝鏂規硶鍚庨兘娌℃湁鎴愬姛錛屽悗鏉ュ彂鐜皊pring绔熺劧瀵筁OB鏈夊緢濂界殑鏀寔銆?/div>

lvq810 2008-09-04 15:10 鍙戣〃璇勮
]]>鍦‵lex涓偣鍑籘ree涓殑涓琛屾墦寮鍏抽棴鑺傜偣[杞琞http://www.tkk7.com/lvq810/articles/226475.htmllvq810lvq810Tue, 02 Sep 2008 11:27:00 GMThttp://www.tkk7.com/lvq810/articles/226475.htmlhttp://www.tkk7.com/lvq810/comments/226475.htmlhttp://www.tkk7.com/lvq810/articles/226475.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/226475.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/226475.html鍦‵lex緙虹渷鐨凾ree緇勪歡涓紝濡傛灉瑕佹墦寮鏌愪釜鑺傜偣鐨勮瘽錛岀偣鍑昏妭鐐規湰韜槸涓嶅ソ鐢ㄧ殑錛屽彧鑳界偣鍑昏妭鐐瑰墠闈㈢殑閭d釜寰堝皬鐨?#8220;涓夎絎﹀彿”錛岃繖縐嶇敤鎴蜂綋楠屽叾瀹炴槸寰堢碂緋曠殑銆備笉榪囨垜浠彲浠ラ氳繃Tree 涓殑 itemClick 浜嬩歡鏉ヨ嚜宸卞疄鐜拌繖涓簨鎯呫?/p>

鍋囪鎴戜滑鏈変竴涓猅ree錛屽畠鐨刬d=”tree”錛屽畾涔変竴涓畠鐨刬temClick浜嬩歡澶勭悊鍑芥暟 itemClickHandler:

private function tree_itemClick(evt:ListEvent):void {
     var item:Object 
= Tree(evt.currentTarget).selectedItem;
    
if (tree.dataDescriptor.isBranch(item)) {
          tree.expandItem(item, 
!tree.isItemOpen(item), true);
     }
}


浠g爜寰堢畝鍗曪紝灝辨槸鍏堣幏鍙栧埌褰撳墠鐐瑰嚮鐨勮妭鐐癸紝鍒ゅ畾瀹冩槸鍚︽槸涓涓灊鑺傜偣錛岀劧鍚庡皢瀹冪殑鎵撳紑鐘舵佹洿鏀廣?/p>

鏈鍚庡湪Tree涓緗?itemClick=”itemClickHandler(event)” 灝監K浜嗐?/p>

main.mxml錛堣嫳鏂囬摼鎺ュ湴鍧錛歨ttp://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/錛?br />

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" viewSourceURL="srcview/index.html">

    
<mx:Script>
        
<![CDATA[
            
import mx.collections.ICollectionView;
            
import mx.events.ListEvent;

            
private function tree_itemClick(evt:ListEvent):void {
                var item:Object 
= Tree(evt.currentTarget).selectedItem;
                
if (tree.dataDescriptor.isBranch(item)) {
                    tree.expandItem(item, 
!tree.isItemOpen(item), true);
                }
            }

            
private function tree_labelFunc(item:XML):String {
                var children:ICollectionView;
                var suffix:String 
= "";
                
if (tree.dataDescriptor.isBranch(item)) {
                    children 
= tree.dataDescriptor.getChildren(item);
                    suffix 
= " (" + children.length + ")";
                }
                
return item[tree.labelField] + suffix;
            }
        ]]
>
    
</mx:Script>

    
<mx:XML id="dp">
        
<root>
            
<folder label="One">
                
<folder label="One.A">
                    
<item label="One.A.1" />
                    
<item label="One.A.2" />
                    
<item label="One.A.3" />
                    
<item label="One.A.4" />
                    
<item label="One.A.5" />
                
</folder>
                
<item label="One.1" />
                
<item label="One.2" />
            
</folder>
            
<folder label="Two">
                
<item label="Two.1" />
                
<folder label="Two.A">
                    
<item label="Two.A.1" />
                    
<item label="Two.A.2" />
                
</folder>
            
</folder>
        
</root>
    
</mx:XML>

    
<mx:Tree id="tree"
            dataProvider
="{dp}"
            showRoot
="false"
            labelField
="@label"
            labelFunction
="tree_labelFunc"
            width
="300"
            rowCount
="6"
            itemClick
="tree_itemClick(event);" />
    
</mx:Application>


lvq810 2008-09-02 19:27 鍙戣〃璇勮
]]>
Spring涓嬩嬌鐢℉ibernate Annotationhttp://www.tkk7.com/lvq810/articles/225815.htmllvq810lvq810Sat, 30 Aug 2008 16:47:00 GMThttp://www.tkk7.com/lvq810/articles/225815.htmlhttp://www.tkk7.com/lvq810/comments/225815.htmlhttp://www.tkk7.com/lvq810/articles/225815.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/225815.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/225815.html1.鍦ㄩ」鐩殑Class Path涓姞鍏ibernate鍜宧ibernate-annotation闇瑕佺殑鍖?br /> 2.鍦⊿pring鐨刟pplicationContext閰嶇疆鏂囦歡涓姞鍏ュ垱寤篐ibernate SessionFactory鐨凢actory Bean瀹氫箟:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
3.鏈鍚庢寜鐓ibernate-annotation reference涓殑瑕佹眰鏉ュ啓瀹炰綋綾?Entity Bean)鐨勬敞瑙?annotation)灝辮浜?
闇瑕佹敞鎰忕殑鏄疈Entity娉ㄨВ瀵瑰簲鐨勭被鏄痡avax.persistence.Entity,鑰屼笉鏄痮rg.hibernate.annotation.Entity.

lvq810 2008-08-31 00:47 鍙戣〃璇勮
]]>
Spring2.5 鍙?Hibernate Annotation 閰嶇疆鏂囦歡絎旇http://www.tkk7.com/lvq810/articles/225813.htmllvq810lvq810Sat, 30 Aug 2008 16:36:00 GMThttp://www.tkk7.com/lvq810/articles/225813.htmlhttp://www.tkk7.com/lvq810/comments/225813.htmlhttp://www.tkk7.com/lvq810/articles/225813.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/225813.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/225813.html   1. <context-param>     &n...  闃呰鍏ㄦ枃

lvq810 2008-08-31 00:36 鍙戣〃璇勮
]]>
鐣?Spring 2.5 閬囦笂 Hibernate Annotations - 鑷嫊鎼滃皨 classpath 鍏х殑 entityhttp://www.tkk7.com/lvq810/articles/225805.htmllvq810lvq810Sat, 30 Aug 2008 15:37:00 GMThttp://www.tkk7.com/lvq810/articles/225805.htmlhttp://www.tkk7.com/lvq810/comments/225805.htmlhttp://www.tkk7.com/lvq810/articles/225805.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/225805.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/225805.html鏈榪戞帹鍑虹殑 Spring 2.5 鎻愬′嬌鐢?annotation 鐨勬柟寮忓彇浠?xml 鐨勮ō瀹氾紝閫欏嬮儴浠藉咕涔庡畬鍏ㄥ彇浠d簡 Spring Annotations 鐨勫姛鑳斤紝鐪嬩締閫欏?project 鎳夎┎宸茬稉娌掓湁浠楹肩敓瀛樼┖闁撱備絾 spring annotations 鐨?hibernate module 鎵鎻愪緵鐨? AutomaticAnnotationSessionFactoryBean 涓鐩存槸鎴戝緢鍠滄鐨勫姛鑳姐備互寰浣跨敤 Hibernate Annotations 鏅傛垜鍊戝彧鑳戒互 fully qualified class name 鎴?fully qualified 鐨?package name 渚嗘寚瀹? entity class銆傞忛亷 AutomaticAnnotationSessionFactoryBean 鎴戝戝彲浠ヨ嚜鍕曟壘鍒版墍鏈夋紺虹偤 @javax.persistence.Entity 鐨?classes 鑷嫊鍔犲叆鍒?hibernate 鐨?mapping classes銆係pring 2.5 鏃㈢劧鏈韓灝卞彲浠ヨ嚜鍕曠殑鎼滃皨鍒?@Component 浠ュ強鐩擱棞鐨?bean class錛岄偅鎴戝戞噳瑭蹭篃鍙互鍋氬埌 @Entity 鐨勬悳灝嬪泬銆?/p>

鎴戞寜鐓?spring annotations 鐨勫仛娉曪紝鎻愪緵涓鍊嬭嚜瑁界殑 session factory bean錛?/p>

import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.TypeFilter;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
import org.springframework.util.ClassUtils;

import javax.persistence.Entity;
import java.io.IOException;

/**
 * Created on: 2007/11/24
 *
 * 
@author Alan She
 
*/
public class ClasspathScanningAnnotationSessionFactoryBean extends AnnotationSessionFactoryBean {

    
private static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
    
private ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    
private MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(this.resourcePatternResolver);
    
private final TypeFilter entityFilter = new AnnotationTypeFilter(Entity.class);
    
private String resourcePattern = DEFAULT_RESOURCE_PATTERN;
    
private String[] basePackages;

    
public void setBasePackages(String basePackages) {
        
this.basePackages = basePackages;
    }

    
protected void postProcessAnnotationConfiguration(AnnotationConfiguration config) throws HibernateException {
        
for (String basePackage : basePackages) {
            
try {
                String packageSearchPath 
= ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
                        ClassUtils.convertClassNameToResourcePath(basePackage) 
+ "/" + this.resourcePattern;
                Resource[] resources 
= this.resourcePatternResolver.getResources(packageSearchPath);
                
for (int i = 0; i < resources.length; i++) {
                    Resource resource 
= resources[i];
                    MetadataReader metadataReader 
= this.metadataReaderFactory.getMetadataReader(resource);
                    
if (isEntity(metadataReader)) {
                        String classFileFullPath 
= resource.getURL().getPath();
                        String basePackageResourcePath 
= ClassUtils.convertClassNameToResourcePath(basePackage);
                        
int startIndex = classFileFullPath.indexOf(basePackageResourcePath);
                        
final String classFilePath = classFileFullPath.substring(startIndex,
                                classFileFullPath.length() 
- ClassUtils.CLASS_FILE_SUFFIX.length());
                        Class entityClass 
= null;
                        
try {
                            entityClass 
= ClassUtils.forName(ClassUtils.convertResourcePathToClassName(classFilePath));
                        } 
catch (ClassNotFoundException e) {
                            
throw new HibernateException("Entity class not found during classpath scanning", e);
                        }
                        config.addAnnotatedClass(entityClass);
                    }
                }
            }
            
catch (IOException ex) {
                
throw new HibernateException("I/O failure during classpath scanning", ex);
            }
        }
    }

    
private boolean isEntity(MetadataReader metadataReader) throws IOException {
        
if (entityFilter.match(metadataReader, this.metadataReaderFactory)) {
            
return true;
        }
        
return false;
    }
}

閫欏?class 鐨勫収瀹規槸浠?Spring 2.5 鐨?ClassPathBeanDefinitionScanner 鐐洪騫硅屼締鐨勩傚師鐞嗗緢綈″柈錛屼互 PathMatchingResourcePatternResolver 鍘繪壘鍒版墍浠?basePackage 涓嬬殑 classes錛屼竴涓姣斿皪鏄惁鏈?annotate 浜?@javax.persistence.Entity錛屽鏋滄湁灝卞姞鍏ュ埌 session factory 鐨?annotationClass銆?/p>

<bean id="sessionFactory" class="package.ClasspathScanningAnnotationSessionFactoryBean">
    
<property name="dataSource" ref="dataSource"/>
    
<property name="hibernateProperties">
    
<props>
        
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
    
</props>
    
</property>
    
<property name="basePackages">
        
<list>
            
<value>package.model</value>
        
</list>
    
</property>
</bean>

浣跨敤涓婁篃闈炲父綈″柈錛岃窡涓鑸?spring 瀹e憡 session factory 涓妯o紝鍙渶鎸囧畾 basePackage 浣滅偤鎼滃皨鐨勭瘎鍦嶅嵆鍙?/p>

鑷嫊鎼滃皨鐣剁劧鏈夊劒榛炰篃鏈夌己榛烇紝浣嗘垜鍊嬩漢璦庡幁涓涓鍘昏ō瀹?entity銆傛湁浜哄彲鑳芥渻瑕哄緱钀竴濡傛灉鎴戞湁鍦?classpath 瑁$殑 entity 鍙堜笉鎯沖姞鍏ラ偅涓嶅氨鍙兘鍏ㄩ兘鐢ㄦ墜鍕曡ō瀹氾紵鍏跺濡傛灉鎯寵鏈変簺褰堟у彲浠ュ姞鍏?include / exclude pattern 絳夋澅瑗匡紝璁撹ō瀹氭洿媧匯傜暍绔熻ō瀹氭獢鏅備唬宸茬稉鎱㈡參閬庡幓錛屽湪 convention over configuration 鐨勫ぇ瓚ㄥ嫝涔嬩笅錛屾兂杈︽硶鍒跺畾瑕忓墖浠ュ強灝囪鍓囦互鑷嫊鍖栬惤瀵︽墠鏄暦涔呬箣璦堛?/p>

lvq810 2008-08-30 23:37 鍙戣〃璇勮
]]>
Hibernate Annotations 鍑犵閰嶇疆http://www.tkk7.com/lvq810/articles/225800.htmllvq810lvq810Sat, 30 Aug 2008 15:21:00 GMThttp://www.tkk7.com/lvq810/articles/225800.htmlhttp://www.tkk7.com/lvq810/comments/225800.htmlhttp://www.tkk7.com/lvq810/articles/225800.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/225800.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/225800.html 涓庡師鏉ヤ嬌鐢↙ocalSessionFactoryBean鐩告瘮錛屽彉鍔ㄤ笉澶э紙AnnotationSessionFactoryBean鏈潵灝辨槸浠嶭ocalSessionFactoryBean綾葷戶鎵胯繃鏉ョ殑鍢涳級
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
      parent
="AbstractSessionFactory">
    
<property name="annotatedClasses">
        
<list>
             
<value>xxx.xxx.xxx.domain.Account</value>
        
</list>
    
</property>
</bean>
<bean id="AbstractSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
      abstract
="true">
    
<property name="dataSource" ref="DataSource" />
         
<property name="hibernateProperties">
             
<props>
                 
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
                 
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                 
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                 
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                 
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
             
</props>
         
</property>
    
<property name="lobHandler" ref="DefaultLobHandler" />
</bean>
2銆乮d鐨勯厤緗?br /> 闈炲父綆鍗曪紝鍦╥d鐨刧etter涓婇潰鍔犱釜“@Id”灝卞彲浠ヤ簡銆傛鏃墮噰鐢ㄧ殑id絳栫暐鏄痡avax.persistence.GenerationType.AUTO錛屼篃鍙互鍐嶅姞涓?“@GeneratedValue(generator =GenerationType.IDENTITY|GenerationType.SEQUENCE|GenerationType.TABLE)”鎹㈡垚鍏跺畠絳栫暐銆?br /> 鎴戠殑搴旂敤閲囩敤鐨勬槸hibernate鐨剈uid絳栫暐錛屽氨涓嶅緱涓嶅湪榪欏効浣跨敤hibernate鐨勬墿灞曚簡
  @Id
  @Column(length 
= 32)
  @GeneratedValue(generator 
= "system-uuid")
  @GenericGenerator(name 
= "system-uuid", strategy = "uuid")
3銆佺駭鑱旂瓥鐣?br /> 鍦╡jb3-persistence.jar涓彧瀹氫箟浜?ALL銆丮ERGE銆丳ERSIST銆丷EFRESH銆丷EMOVE錛屾瘮杈冩伓蹇冪殑灝辨槸錛屽垹闄ゅ璞$殑鏃跺欙紝騫朵笉浼氱駭鑱斿垹闄ゅ叧鑱斿璞★紝鑰屾槸鐢╱pdate xx set parent_id=null where parent_id=?榪欑被璇彞鎶婂叧緋誨共鎺変簡浜嬨備笉寰楀凡錛屽湪榪欏効鐢ㄤ簡hibernate鐨凞ELETE_ORPHAN銆?br />
  @OneToMany(targetEntity = Attachment.class)
  @Cascade(value 
= {org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
      org.hibernate.annotations.CascadeType.ALL})
  @JoinColumn(name 
= "info_id")
4銆丆ACHE
ejb3-persistence.jar閲岄潰娌℃湁鎵懼埌cache鐨勯厤緗紝緇х畫璇峰嚭hibernate鏉ュ共媧?br />
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name 
= "T_INFO")
@Cache(usage 
= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
5銆佽嚜瀹氫箟瀛楁綾誨瀷
鎴戠殑POJO涓湁涓涓猵rivate String content;鐨勫睘鎬э紝鎸塭jb3閰嶆垚@Lob鍚庯紝琚鐞嗘垚浜唗ext綾誨瀷錛宼ext 64k鐨勫瓨鍌ㄥ閲忚繕鏄瘮杈冨彲鎬滀簡銆?br />
  @Lob
  @Column(columnDefinition 
= "LongText")



lvq810 2008-08-30 23:21 鍙戣〃璇勮
]]>
甯哥敤鐨凷truts 2.0鏍囩搴揫杞琞http://www.tkk7.com/lvq810/articles/225038.htmllvq810lvq810Wed, 27 Aug 2008 06:43:00 GMThttp://www.tkk7.com/lvq810/articles/225038.htmlhttp://www.tkk7.com/lvq810/comments/225038.htmlhttp://www.tkk7.com/lvq810/articles/225038.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/225038.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/225038.html闃呰鍏ㄦ枃

lvq810 2008-08-27 14:43 鍙戣〃璇勮
]]>
Spring 鍔ㄦ佹暟鎹簮 [杞琞http://www.tkk7.com/lvq810/articles/219148.htmllvq810lvq810Thu, 31 Jul 2008 12:13:00 GMThttp://www.tkk7.com/lvq810/articles/219148.htmlhttp://www.tkk7.com/lvq810/comments/219148.htmlhttp://www.tkk7.com/lvq810/articles/219148.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/219148.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/219148.htmlSpring 鍙互璁劇疆鍔ㄦ佹暟鎹簮錛岃繖鏍峰彲浠ュ紼嬪簭鏉ラ忔槑鐨勬敮鎸佸垏鎹㈡搷浣滀笉鍚岀殑鏁版嵁搴撱?/p>

http://oiote.blog.sohu.com/74596942.html 榪欑瘒鏂囩珷鍐欏緱闈炲父涓嶉敊銆傛祴璇曢氳繃錛屽茍鍑嗗鍦ㄩ」鐩腑浣跨敤榪欎釜鏂規硶銆傝繕鏈夊嚑涓棶棰樺笇鏈涘ぇ瀹剁粰鐐規剰瑙侊細

棣栧厛璇翠竴涓嬫垜鐨勯渶姹傦細鏁版嵁搴撶粨鏋勯兘鏄竴鏍鳳紝浣嗗叿浣撴湁澶氬皯涓暟鎹簱涓嶇‘瀹氾紙瑙嗗叿浣撶敤鎴瘋屽畾錛夛紝鐢ㄦ埛鎿嶄綔閭d釜鏁版嵁搴撹鏍規嵁鐧誨綍鐨勬椂鍊欒繘琛岄夋嫨錛屾垨鏍規嵁鐢ㄦ埛鐨勬潈闄愯屽畾銆傝繖涓俊鎭偗瀹氭槸淇濆瓨鍦ㄧ敤鎴風殑鐧誨綍淇℃伅涓?渚嬪錛歴ession錛?/p>

闂1銆佸綋鏈変笉鍚岀殑鐢ㄦ埛闇瑕佹搷浣滀笉鍚岀殑鏁版嵁搴撴椂錛堟牴鎹櫥褰曟椂鐨勯夋嫨鎴栨寚瀹氾級錛屼粈涔堟椂鍊欏垏鎹㈡暟鎹簱錛熸槸鍦╯ervice灞傝繕鏄痙ao灞傦紵榪欎釜淇℃伅鎬庝箞浼犵粰灞備腑鐨勬柟娉曪紵濡傛灉姣忎釜鏂規硶閮藉姞涓涓弬鏁拌繖鏍蜂笉澶ソ鍚э紵

闂2銆佽繖涓綣佺殑鏇存崲鏁版嵁搴擄紝浼氫笉浼氭湁鎬ц兘褰卞搷錛熷洜涓簊essionFactory鏄竴涓垏鎹㈡暟鎹簱鏄笉鏄氨鏄噸鏂板垵濮嬩竴嬈essionFactory?


闄勫師鏂囧涓嬶細

Spring2.0.1浠ュ悗鐨勭増鏈凡緇忔敮鎸侀厤緗鏁版嵁婧愶紝騫朵笖鍙互鍦ㄨ繍琛岀殑鏃跺欏姩鎬佸姞杞戒笉鍚岀殑鏁版嵁婧愩傞氳繃緇ф壙 AbstractRoutingDataSource灝卞彲浠ュ疄鐜板鏁版嵁婧愮殑鍔ㄦ佽漿鎹€傜洰鍓嶅仛鐨勯」鐩氨鏄渶瑕佽闂?2涓暟鎹簮錛屾瘡涓暟鎹簮鐨勮〃緇撴瀯閮芥槸鐩稿悓鐨勶紝鎵浠ヨ姹傛暟鎹簮鐨勫彉鍔ㄥ浜庣紪鐮佷漢鍛樻潵璇存槸閫忔槑錛屼篃灝辨槸璇村悓鏍稴QL璇彞鍦ㄤ笉鍚岀殑鐜涓嬫搷浣滅殑鏁版嵁搴撴槸涓嶄竴鏍風殑銆傚叿浣撶殑閰嶇疆濡備笅錛?br /> 涓銆侀鍏堥渶瑕佸啓涓涓潤鎬佺殑閿煎鐓х被錛?/p>

浠g爜

  1. package cn.com.xinli.ccp.dynamicds;
  2. public class DataSourceMap {
  3. public static final String Admin="Admin";
  4. public static final String Yxh = "Yxh";
  5. }

榪欎釜綾諱富瑕佸湪浣跨敤鐨勬椂鍊欏綋浣滆幏寰楁暟鎹簮鐨勬爣蹇椾嬌鐢ㄣ?br /> 浜屻佸緩绔嬩竴涓幏寰楀拰璁劇疆涓婁笅鏂囩殑綾伙細

浠g爜

  1. package cn.com.xinli.ccp.dynamicds;
  2. public class CustomerContextHolder {
  3. private static final ThreadLocal contextHolder =
  4. new ThreadLocal();
  5. public static void setCustomerType(String customerType) {
  6. contextHolder.set(customerType);
  7. }
  8. public static String getCustomerType() {
  9. return (String) contextHolder.get();
  10. }
  11. public static void clearCustomerType() {
  12. contextHolder.remove();
  13. }
  14. }
榪欎釜涓昏璐熻矗璁劇疆涓婁笅鏂囩幆澧冨拰鑾峰緱涓婁笅鏂囩幆澧冦?br />

涓夈佸緩绔嬪姩鎬佹暟鎹簮綾伙紝榪欎釜綾誨繀欏葷戶鎵緼bstractRoutingDataSource錛?br />

浠g爜

  1. package cn.com.xinli.ccp.dynamicds;
  2. import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
  3. public class DynamicDataSource extends AbstractRoutingDataSource {
  4. protected Object determineCurrentLookupKey() {
  5. // TODO Auto-generated method stub
  6. return CustomerContextHolder.getCustomerType();
  7. }
  8. }
榪欎釜綾誨疄鐜頒簡 determineCurrentLookupKey鏂規硶錛岃鏂規硶榪斿洖涓涓狾bject錛屼竴鑸槸榪斿洖瀛楃涓詫紝涔熷彲浠ユ槸鏋氫婦綾誨瀷銆傝鏂規硶涓洿鎺ヤ嬌鐢ㄤ簡 CustomerContextHolder.getCustomerType()鏂規硶鑾峰緱涓婁笅鏂囩幆澧冨茍鐩存帴榪斿洖銆?br />

鍥涖佺紪鍐檚pring鐨勯厤緗枃浠墮厤緗暟鎹簮

浠g爜

  1. <bean id="parentDataSource"
  2. class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  3. <property name="driverClassName">
  4. <value>COM.ibm.db2.jdbc.net.DB2Driver</value>
  5. </property>
  6. <property name="url">
  7. <value>jdbc:db2:127.0.0.1:TEST</value>
  8. </property>
  9. </bean>
  10. <bean id="adminDataSource" parent="parentDataSource">
  11. <property name="username" value="admin"/>
  12. <property name="password" value="master997mb"/>
  13. </bean>
  14. <bean id="yxhDataSource" parent="parentDataSource">
  15. <property name="username" value="yxh"/>
  16. <property name="password" value="yxh"/>
  17. </bean>
鍦ㄨ繖涓厤緗腑鍙互鐪嬪埌棣栧厛鏈変釜parentDataSource錛岃繖涓富瑕侀厤緗竴浜涙暟鎹簮鐨勫叕鐢ㄤ俊鎭紝欏圭洰涓兘鏄摼鎺B2鏁版嵁搴擄紱adminDataSource鍜寉xhDataSource鏄牴鎹笉鍚岄渶瑕侀厤緗殑涓у寲淇℃伅錛屼絾閮藉繀欏誨姞parent灞炴э紝鍊間負 parentDataSource銆傝繖鏍峰氨閰嶇疆濂戒簡2涓暟鎹簮淇℃伅銆傚綋鐒跺鏋滈摼鎺ョ殑澶氭暟鎹簮鏄笉鍚岀被鍨嬬殑涓や釜鏁版嵁搴擄紝閭d箞 parentDataSource灝卞彲浠ヤ笉瑕佷簡錛岀洿鎺ラ厤緗袱涓笉鍚岀殑鏁版嵁婧愰摼鎺ュ氨鍙互浜嗐?br />

浜斻佺紪鍐檚pring閰嶇疆鏂囦歡閰嶇疆澶氭暟鎹簮鏄犲皠鍏崇郴

浠g爜

  1. <bean id="dataSource" class="cn.com.xinli.ccp.dynamicds.DynamicDataSource">
  2. <property name="targetDataSources">
  3. <map key-type="java.lang.String">
  4. <!-- entry鍏冪礌涓殑key涓?/span>AbstractRoutingDataSource綾葷殑determineCurrentLookupKey()鏂規硶鐨勮繑鍥炲煎尮閰?/span> -->
  5. <entry key="Yxh" value-ref="yxhDataSource"/>
  6. </map>
  7. </property>
  8. <property name="defaultTargetDataSource" ref="adminDataSource"/>
  9. </bean>
鍦ㄨ繖涓厤緗腑絎竴涓猵roperty灞炴ч厤緗洰鏍囨暟鎹簮錛?lt;map key-type="java.lang.String">涓殑key-type蹇呴』瑕佸拰闈欐侀敭鍊煎鐓х被DataSourceMap涓殑鍊肩殑綾誨瀷鐩稿悓錛?lt;entry key="Yxh" value-ref="yxhDataSource"/>涓璳ey鐨勫煎繀欏昏鍜岄潤鎬侀敭鍊煎鐓х被涓殑鍊肩浉鍚岋紝濡傛灉鏈夊涓鹼紝鍙互閰嶇疆澶氫釜< entry>鏍囩銆傜浜屼釜property灞炴ч厤緗粯璁ょ殑鏁版嵁婧愩?br />

鍏侀厤緗甴ibernate銆?br /> Hibernate鐨勯厤緗拰鏅氱殑hibernate銆乻pring緇撳悎鐨勯厤緗竴鏍?br />

浠g爜

  1. <bean id="sessionFactory"
  2. class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  3. <!-- to override, use the "SpringDatasourceConfig" snippet in your project -->
  4. <property name="dataSource">
  5. <ref local="dataSource" />
  6. </property>
  7. <property name="mappingResources">
  8. <list>
  9. <value>
  10. cn/com/xinli/ccp/entity/User.hbm.xml
  11. </value>
  12. <value>
  13. cn/com/xinli/ccp/entity/Test.hbm.xml
  14. </value>
  15. </list>
  16. </property>
  17. <property name="hibernateProperties">
  18. <props>
  19. <prop key="hibernate.dialect">
  20. org.hibernate.dialect.DB2Dialect
  21. </prop>
  22. <prop key="hibernate.show_sql">true</prop>
  23. <prop key="hibernate.use_outer_join">true</prop>
  24. <prop key="hibernate.jdbc.batch_size">50</prop>
  25. <prop key="hibernate.jdbc.fetch_size">5</prop>
  26. <prop key="hibernate.connection.pool_size">2</prop>
  27. <prop key="hibernate.connection.autocommit">false</prop>
  28. <prop key="hibernate.cache.use_query_cache">false</prop>
  29. <prop key="hibernate.max_fetch_depth">1</prop>
  30. <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
  31. </props>
  32. </property>
  33. </bean>
  34. <bean id="mydao" class="cn.com.xinli.ccp.dao.HibernateBaseDao">
  35. <property name="sessionFactory">
  36. <ref local="sessionFactory" />
  37. </property>
  38. </bean>
鍏充簬dao鐨勪唬鐮佽繖閲屽氨鐪佺暐浜嗐?br />

涓冦侀厤緗粨鏉燂紝鍙互浣跨敤浜嗐?br />

浠g爜

  1. public class DaoTest extends TestCase {
  2. public void testSave() throws Exception{
  3. CustomerContextHolder.setCustomerType(DataSourceMap.Admin);//璁劇疆鏁版嵁婧?/span>
  4. //hibernate鍒涘緩瀹炰綋
  5. Test test = new Test();
  6. test.setTest("22222222");
  7. mydao.save(test);//浣跨敤dao淇濆瓨瀹炰綋
  8. CustomerContextHolder.setCustomerType(DataSourceMap.Yxh);//璁劇疆涓哄彟涓涓暟鎹簮
  9. mydao.save(test);//浣跨敤dao淇濆瓨瀹炰綋鍒板彟涓涓簱涓?/span>
  10. }
  11. }

鍦ㄩ」鐩腑瀵逛簬緙栫爜浜哄憳瀵瑰鏁版嵁婧愮殑鍒囨崲鍙互鍋氭垚閫忔槑鐨勶紝鎿嶄綔鍚屾牱鐨刣ao錛屽氨鍙互璁塊棶涓嶅悓鐨勬暟鎹簱浜嗐?/p>

lvq810 2008-07-31 20:13 鍙戣〃璇勮
]]>
StAXhttp://www.tkk7.com/lvq810/articles/215883.htmllvq810lvq810Fri, 18 Jul 2008 11:15:00 GMThttp://www.tkk7.com/lvq810/articles/215883.htmlhttp://www.tkk7.com/lvq810/comments/215883.htmlhttp://www.tkk7.com/lvq810/articles/215883.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/215883.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/215883.htmlXML澶勭悊API,瀹冭兘澶熶粠搴旂敤紼嬪簭鐨?a title="Stream">stream瀵硅薄瑙f瀽XML鏁版嵁鎴栨妸XML鏁版嵁杞崲鎴恠tream瀵硅薄銆係tAX鏄竴涓敤Java瀹炵幇鐨刋ML鎷夊紡瑙f瀽鍣ㄣ?

lvq810 2008-07-18 19:15 鍙戣〃璇勮
]]>
Hibernate+Spring鎼炲畾Clob銆丅lob鐨勫瓨鍙朳杞琞http://www.tkk7.com/lvq810/articles/205917.htmllvq810lvq810Wed, 04 Jun 2008 12:43:00 GMThttp://www.tkk7.com/lvq810/articles/205917.htmlhttp://www.tkk7.com/lvq810/comments/205917.htmlhttp://www.tkk7.com/lvq810/articles/205917.html#Feedback0http://www.tkk7.com/lvq810/comments/commentRss/205917.htmlhttp://www.tkk7.com/lvq810/services/trackbacks/205917.html鎽樿錛氭湰鏂囬氳繃涓涓疄渚嬭榪板浣曢氳繃Spring2+Hibernate3鏉ュ揩鎹鋒搷浣滄暟鎹簱涓殑Lob瀛楁銆?br /> 鐜錛歄racle10g銆丼rping2銆丠ibernate3銆丣Uint4

涓銆佸垱寤哄疄浣撳茍娣誨姞Xdoclet鐨凥ibernate鏍囩

/**
* @author leizhimin
* @hibernate.mapping default-lazy="false"
* @hibernate.meta attribute="class-description" value="宸ヤ綔鏃ュ織"
* @hibernate.class table="rc_gzrz"
*/
public class WorkNote {
  private Long id;             //鏍囪瘑
  private Date workDate;         //鏃ユ湡
  private String weather;         //澶╂皵
  private String content;         //鏃ュ織鍐呭(Clob)
  private String state;           //鏃ュ織鐘舵?br />   private Long orgId;           //鏈烘瀯id
  private Long userId;           //鐢ㄦ埛id
  private Date createDate;         //鍒涘緩鏃ユ湡
  private byte[] image;           //鍥劇墖

  public static final String WORKNOTE_BLANK = "00";       //鏈~鍐?br />   public static final String WORKNOTE_FULL = "11";       //宸插~鍐?br />
  /**
  * @hibernate.id generator-class="sequence" column="BS"
  * @hibernate.meta attribute="field-description" value="鏍囪瘑"
  * @hibernate.generator-param name="sequence" value="SEQ_GW"
  */
  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  /**
  * @hibernate.property column="workDate" not-null="false" type="timestamp"
  * @hibernate.meta attribute="field-description" value="宸ヤ綔鏃ユ湡"
  */

  public Date getWorkDate() {
    return workDate;
  }

  public void setWorkDate(Date workDate) {
    this.workDate = workDate;
  }

  /**
  * @hibernate.property column="weather" not-null="false" length="24"
  * @hibernate.meta attribute="field-description" value="澶╂皵"
  */
  public String getWeather() {
    return weather;
  }

  public void setWeather(String weather) {
    this.weather = weather;
  }

  /**
  * @hibernate.property column="content" not-null="false" type="text"
  * @hibernate.meta attribute="field-description" value="鍐呭"
  */
  public String getContent() {
    return content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  /**
  * @hibernate.property column="state" not-null="false" length="2"
  * @hibernate.meta attribute="field-description" value="鐘舵?
  */
  public String getState() {
    return state;
  }

  public void setState(String state) {
    this.state = state;
  }

  /**
  * @hibernate.property column="orgId" type="long"
  * @hibernate.meta attribute="field-description" value="鏈烘瀯id"
  */
  public Long getOrgId() {
    return orgId;
  }

  public void setOrgId(Long orgId) {
    this.orgId = orgId;
  }

  /**
  * @hibernate.property column="userId" type="long"
  * @hibernate.meta attribute="field-description" value="鐢ㄦ埛id"
  */
  public Long getUserId() {
    return userId;
  }

  public void setUserId(Long userId) {
    this.userId = userId;
  }

  /**
  * @hibernate.property column="createDate" not-null="false" type="timestamp"
  * @hibernate.meta attribute="field-description" value="鍒涘緩鏃ユ湡"
  */
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  /**
  * @hibernate.property column="image" type="blob" not-null="false"
  * @hibernate.meta attribute="field-description" value="鍥劇墖"
  */
  public byte[] getImage() {
    return image;
  }

  public void setImage(byte[] image) {
    this.image = image;
  }
}

浜屻侀氳繃XDoclet鐢熸垚Mapping錛屽茍淇lob鏄犲皠鐨勭被鍨嬩負Spring鎻愪緵鐨勭被鍨?br />
<?xml version="1.0" encoding="gb2312"?>

<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
    default-lazy="false"
>
  <class
    name="com.topsoft.oa.routine.domain.office.entity.WorkNote"
    table="rc_gzrz"
  >
    <meta attribute="class-description">宸ヤ綔鏃ュ織</meta>

    <id
        name="id"
        column="BS"
        type="java.lang.Long"
    >
        <meta attribute="field-description">鏍囪瘑</meta>
        <generator class="sequence">
          <param name="sequence">SEQ_GW</param>
        <!--
            To add non XDoclet generator parameters, create a file named
            hibernate-generator-params-WorkNote.xml
            containing the additional parameters and place it in your merge dir.
        -->
        </generator>
    </id>

    <property
        name="workDate"
        type="timestamp"
        update="true"
        insert="true"
        column="workDate"
        not-null="false"
    >
        <meta attribute="field-description">宸ヤ綔鏃ユ湡</meta>
    </property>

    <property
        name="weather"
        type="java.lang.String"
        update="true"
        insert="true"
        column="weather"
        length="24"
        not-null="false"
    >
        <meta attribute="field-description">澶╂皵</meta>
    </property>

    <property
        name="content"
        type="org.springframework.orm.hibernate3.support.ClobStringType"
        update="true"
        insert="true"
        column="content"
        not-null="false"
    >
        <meta attribute="field-description">鍐呭</meta>
    </property>

    <property
        name="state"
        type="java.lang.String"
        update="true"
        insert="true"
        column="state"
        length="2"
        not-null="false"
    >
        <meta attribute="field-description">鐘舵?lt;/meta>
    </property>

    <property
        name="orgId"
        type="long"
        update="true"
        insert="true"
        column="orgId"
    >
        <meta attribute="field-description">鏈烘瀯id</meta>
    </property>

    <property
        name="userId"
        type="long"
        update="true"
        insert="true"
        column="userId"
    >
        <meta attribute="field-description">鐢ㄦ埛id</meta>
    </property>

    <property
        name="createDate"
        type="timestamp"
        update="true"
        insert="true"
        column="createDate"
        not-null="false"
    >
        <meta attribute="field-description">鍒涘緩鏃ユ湡</meta>
    </property>

    <property
        name="image"
        type="org.springframework.orm.hibernate3.support.BlobByteArrayType"
        update="true"
        insert="true"
        column="image"
        not-null="false"
    >
        <meta attribute="field-description">鍥劇墖</meta>
    </property>

    <!--
        To add non XDoclet property mappings, create a file named
          hibernate-properties-WorkNote.xml
        containing the additional properties and place it in your merge dir.
    -->

  </class>

</hibernate-mapping>



涓夈侀氳繃Mapping 鐢╔Doclet鐢熸垚鏁版嵁搴擄紙Oracle錛夎剼鏈紝騫跺緩琛?br />
  drop table rc_gzrz cascade constraints;


  create table rc_gzrz (
    BS number(19,0) not null,
    workDate timestamp,
    weather varchar2(24 char),
    content clob,
    state varchar2(2 char),
    orgId number(19,0),
    userId number(19,0),
    createDate timestamp,
    image blob,
    primary key (BS)
  );

  comment on table rc_gzrz is
    '宸ヤ綔鏃ュ織'

  comment on column rc_gzrz.BS is
    '鏍囪瘑'

  comment on column rc_gzrz.workDate is
    '宸ヤ綔鏃ユ湡'

  comment on column rc_gzrz.weather is
    '澶╂皵'

  comment on column rc_gzrz.content is
    '鍐呭'

  comment on column rc_gzrz.state is
    '鐘舵?

  comment on column rc_gzrz.orgId is
    '鏈烘瀯id'

  comment on column rc_gzrz.userId is
    '鐢ㄦ埛id'

  comment on column rc_gzrz.createDate is
    '鍒涘緩鏃ユ湡'

  comment on column rc_gzrz.image is
    '鍥劇墖'



鍥涖佸垱寤篋AO灞?br />

/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 10:55:50
* To change this template use File | Settings | File Templates.
*/
public interface WorkNoteDAO extends CommonDAO {
  /**
  * 鏍規嵁鏃ユ湡鏌ヨ宸ヤ綔鏃ュ織
  *
  * @param workDate 宸ヤ綔鏃ユ湡
  * @param userId   鐢ㄦ埛id
  * @param orgId   鏈烘瀯id
  * @param sp     鍒嗛〉瀵硅薄
  * @return List
  */
  public List findWorkNoteByDate(Date workDate, Long userId, Long orgId, SplitPage sp);

  /**
  * 鏍規嵁鐘舵佹煡璇㈠伐浣滄棩蹇?br />   *
  * @param state   鏃ュ織鐘舵?br />   * @param userId   鐢ㄦ埛id
  * @param orgId   鏈烘瀯id
  * @param sp     鍒嗛〉瀵硅薄
  * @return List
  */
  public List findWorkNoteByState(String state, Long userId, Long orgId, SplitPage sp);
}



/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 10:56:00
* To change this template use File | Settings | File Templates.
*/
public class WorkNoteDAOImpl extends CommonDAOImpl implements WorkNoteDAO{
  public List findWorkNoteByDate(Date workDate, Long userId, Long orgId, SplitPage sp) {
    return null;
  }

  public List findWorkNoteByState(String state, Long userId, Long orgId, SplitPage sp) {
    return null;
  }
}


浜斻佸垱寤哄甫JTA浜嬪姟鎺у埗鐨勪笟鍔ervice灞?br />
/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 16:43:57
* To change this template use File | Settings | File Templates.
*/
public interface OfficeService {

  public void saveWorkNote(WorkNote workNote);

  public void updateWorkNote(WorkNote workNote);
}


/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 16:45:54
* To change this template use File | Settings | File Templates.
*/
public class OfficeServiceImpl implements OfficeService{
  private WorkNoteDAO workNoteDAO;

  public WorkNoteDAO getWorkNoteDAO() {
    return workNoteDAO;
  }

  public void setWorkNoteDAO(WorkNoteDAO workNoteDAO) {
    this.workNoteDAO = workNoteDAO;
  }

  public void saveWorkNote(WorkNote workNote) {
    this.workNoteDAO.saveObject(workNote);
  }

  public void updateWorkNote(WorkNote workNote) {
    this.workNoteDAO.updateObject(workNote);
  }
}


鍏佷功鍐欏崟鍏冩祴璇曪紝騫惰繍琛?br /> /**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 16:49:17
* To change this template use File | Settings | File Templates.
*/
public class TestOffice extends TestCase {
  public void test_worknote_save(){
    OfficeService officeService = (OfficeService) ContextHelper.getContext().getBean("officeServiceProxy");
    WorkNote workNote=new WorkNote();
    workNote.setContent("http://lavasoft.blog.51cto.com/");
    workNote.setOrgId(Long.parseLong("999"));
    workNote.setCreateDate(new Date());
    byte[] b="lavasoft".getBytes();
    workNote.setImage(b);
    officeService.saveWorkNote(workNote);
  }
}

鐪嬬湅嫻嬭瘯緇撴灉錛?br />




lvq810 2008-06-04 20:43 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲一级免费毛片| 亚洲一区二区精品视频| 黄色视屏在线免费播放| 羞羞视频免费网站入口| 国产精品亚洲自在线播放页码| 亚洲经典在线中文字幕| 国产性爱在线观看亚洲黄色一级片| 亚洲毛片网址在线观看中文字幕| 亚洲精品中文字幕乱码三区| 亚洲色图在线播放| 免费人成在线观看网站品爱网| 亚洲A∨精品一区二区三区下载| 一本一道dvd在线观看免费视频 | 亚洲国产精品一区二区第一页免| 亚洲无线观看国产精品| 国产成人99久久亚洲综合精品| 久久久久亚洲AV无码网站| 黑人精品videos亚洲人| 最新亚洲卡一卡二卡三新区| 亚洲五月午夜免费在线视频| 国产成人免费高清激情视频| 亚洲国产另类久久久精品黑人| 亚洲欧美国产欧美色欲| 看亚洲a级一级毛片| 久久午夜无码免费| 亚洲欧洲日韩综合| 午夜dj在线观看免费视频| 性xxxx视频播放免费| 亚洲国产精品无码久久久蜜芽| 亚洲欧美日韩中文字幕一区二区三区| 免费毛片网站在线观看| 亚洲国产成人手机在线电影bd| 成年女人A毛片免费视频| 国产精品另类激情久久久免费| 亚洲日本香蕉视频| 免费国产不卡午夜福在线| 亚洲五月综合网色九月色| 久久国产精品成人片免费| 中文亚洲成a人片在线观看| 亚洲av色香蕉一区二区三区 | 毛片免费在线播放|