女同久久另类99精品国产,国产 日韩 欧美 综合 一区,免费在线观看成人http://www.aygfsteel.com/fine/category/11897.htmlzh-cnWed, 13 Jun 2007 23:26:48 GMTWed, 13 Jun 2007 23:26:48 GMT60Spring Mvchttp://www.aygfsteel.com/fine/archive/2007/06/12/123579.htmlPeter PanPeter PanTue, 12 Jun 2007 05:05:00 GMThttp://www.aygfsteel.com/fine/archive/2007/06/12/123579.htmlhttp://www.aygfsteel.com/fine/comments/123579.htmlhttp://www.aygfsteel.com/fine/archive/2007/06/12/123579.html#Feedback0http://www.aygfsteel.com/fine/comments/commentRss/123579.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/123579.htmlDispatcherServlet)、處理器映射(handler mapping)、視圖解析器(view resolver)等等
控制器(Controller)?實(shí)現(xiàn)的是MVC中C 那個(gè)組成部分。
處理器映射(Handler mapping)包含預(yù)處理器(pre-processor),后處理器(post-processor)和控制器的列表,它們?cè)诜夏撤N條件時(shí)才被執(zhí)行(例如符合控制器指定的URL)。
視圖解析器(View resolvers)可以將視圖名解析為對(duì)應(yīng)的視圖。
本地化解析器(Locale resolver)能夠解析用戶正在使用的本地化設(shè)置,以提供國(guó)際化視圖。
主題解析器(Theme resolver)能夠解析你的web應(yīng)用所使用的主題,以提供個(gè)性化的布局。
上傳文件解析器(multipart file resolver)提供HTML表單文件上傳功能。
處理器異常解析器(Handler exception resolver(s))可以將異常對(duì)應(yīng)到視圖,或者實(shí)現(xiàn)更加復(fù)雜的異常處理代碼。


]]>
Jpa (EJB3 Entity Bean) 好東西就順便拿來(lái)了http://www.aygfsteel.com/fine/archive/2007/04/05/108679.htmlPeter PanPeter PanThu, 05 Apr 2007 05:30:00 GMThttp://www.aygfsteel.com/fine/archive/2007/04/05/108679.htmlhttp://www.aygfsteel.com/fine/comments/108679.htmlhttp://www.aygfsteel.com/fine/archive/2007/04/05/108679.html#Feedback0http://www.aygfsteel.com/fine/comments/commentRss/108679.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/108679.htmlJava EE5到底有什么系列 – Java Persistence API 1.0( EJB3 Entity Bean)
作者:黃海波(Charles Huang)

Java EE5作為新一代Java企業(yè)開(kāi)發(fā)平臺(tái)的規(guī)范,從開(kāi)始設(shè)計(jì)就引來(lái)了整個(gè)java開(kāi)發(fā)社區(qū)的注目,引起無(wú)數(shù)的辯論和帶來(lái)了眾多的期盼。Java EE5作為J2EE平臺(tái)誕生幾近6年后的第4代規(guī)范重點(diǎn)關(guān)注的是目前java開(kāi)發(fā)的幾個(gè)熱點(diǎn):開(kāi)發(fā)效率,運(yùn)行效率和企業(yè)應(yīng)用整合。目標(biāo)也是讓J2EE開(kāi)發(fā)簡(jiǎn)單,簡(jiǎn)單再簡(jiǎn)單。那我們就看看J2EE5規(guī)范到底有什么,是否真的能給開(kāi)發(fā)者/企業(yè)帶來(lái)真正的實(shí)惠?

Java EE5規(guī)范是一個(gè)所謂的雨傘規(guī)范(Umbrella),在其下是一系列的子規(guī)范,主要包括:

EJB 3.0 (JSR 220)
Java Persistence API 1.0 (JSR 220)
JSP 2.1 (JSR 245)
JSF 1.2 (JSR 252)
JAX-WS 2.0 (JSR 224)
StAX 1.0 (JSR 173)
JAXB 2.0 (JSR 222)
Web Services Annotations 1.0 (JSR 181)
Common Annotations 1.0 (JSR 250)
SAAJ 1.3 maintenance
JTA 1.1 maintenance
JavaMail 1.4 & JAF 1.1 maintenance
JSTL 1.2 maintenance
Java EE Mgmt maintenance
JACC maintenance
Servlet maintenance
Java EE Deployment maintenance
WSEE maintenance


Java Persistence API 1.0( EJB3 Entity Bean) 在Java EE5中, Entity Bean做為EJB規(guī)范中負(fù)責(zé)持久化的組件將逐漸成為一個(gè)歷史名詞了,作為J2EE 4規(guī)范中最為人所垢病的Entity Bean在Java EE5中被推到重來(lái),取而代之的是java開(kāi)發(fā)的通用持久化規(guī)范Java Persistence API 1.0, 其實(shí)就是完全重新定義了的Entity Bean規(guī)范(目前在很多場(chǎng)合中,由于歷史原因我們?nèi)匀皇褂胑jb3持久化來(lái)稱(chēng)呼這個(gè)規(guī)范)。JPA作為java中負(fù)責(zé)關(guān)系數(shù)據(jù)持久化的組件已經(jīng)完全獨(dú)立出來(lái)成為一個(gè)單獨(dú)的規(guī)范,而不再屬于Enterprise Java Bean的范疇(EJB更多的是指Stateless/Stateful session bean和Message Driven Bean)。

Java Persistence AP(JPA)可以說(shuō)是java持久化技術(shù)的一個(gè)集大成者,它吸取了Hiberante,JDO,TopLink等優(yōu)秀技術(shù)和框架,將這幾年發(fā)展成熟起來(lái)的基于POJO模型的O/R Mapping技術(shù)標(biāo)準(zhǔn)化,成為在J2EE和J2SE環(huán)境中通用的java持久化API。值得注意的是Java Persistence API并不是J2EE環(huán)境專(zhuān)用,而是在java中的通用API。意味著我們可以在任何需要訪問(wèn)關(guān)系數(shù)據(jù)庫(kù)的地方使用JPA,甚至包括swing開(kāi)發(fā)的桌面應(yīng)用。JPA也不要求一定在J2EE容器中才能運(yùn)行,而是任何有JVM的環(huán)境都可以運(yùn)用。 這就使得我們可以很容易的把JPA作為一個(gè)持久化組件自由的和各種容器/框架(EJB3容器, Spring等等)組合。

JPA如何簡(jiǎn)化原來(lái)EJB2中Entity Bean的開(kāi)發(fā),看一個(gè)簡(jiǎn)單對(duì)比:
EJB2.0EJB3.0(JPA)
Business Interface
public inerface HelloWold extends EJBLocalObject{
    Public String getResult();
}
						
無(wú)需定義接口
映射配置文件編寫(xiě)EJB3 Deployment descriptor可選
EJB實(shí)現(xiàn)
public class HelloWorldEntityBean 
         implements HelloWold, EntityBean{
    private int id;
    private String result;
    private EntityContext txt;
   
    public HelloWorldEntityBean(){}
    public void setEntityContext( EntityContext text ){ 
        txt = text;
    }
   
    public String getResult(){ 
        Return result; 
    }
        
    public int getId(){
        return id; 
    }
    
    public void setResult( String result ){ 
        this.result = result;
    }
    
    public String cretaeByName( String name ) throws EJBException{
        .....
    }
   
 }						
						
@Entity
@Table(name=”hellotable”)
public class HelloWoldEntity{   
    @Id
    private int id; p
    private String result; 
    
    public HelloWoldEntity(){} 
    
    public String getResult(){ 
        return result;
    }
    
    public int getId(){
        return id;
    }  
    
    public void setResult( String result ){ 
        this.result = result;
    }
}						
						

在JPA 中,ejb3的Entity Bean就是一個(gè)簡(jiǎn)單的java bean,即POJO( Plain Old Java Object)。不象EJB2中的EntityBean需要跟容器有密切的關(guān)聯(lián)(EJB2中必須有EntityContext),EJB3 中的entityBean和容器無(wú)關(guān),事實(shí)上在JPA中,EntityBean也不再稱(chēng)為EntityBean,而是Entity,和Session Bean/Message Driven Bean的仍然存在的EJB區(qū)別開(kāi)來(lái)。

為了簡(jiǎn)化O/R Mapping的配置,JPA大量采用JDK1.5的最重要的新特性annotaion直接在java代碼中進(jìn)行配置的標(biāo)注。 采用annotation標(biāo)注O/R Mapping配置可以大幅度減少以往使用xml配置O/R Mapping工作量,提高效率和可維護(hù)性。

下面是一個(gè)最簡(jiǎn)單的一對(duì)一關(guān)聯(lián)關(guān)系采用annotation和xml的配置比較。
Java Persistence API(EJB3 Persistence)Hiberante
配置文件可選需要
One-To-One配置可選
<one-to-one        
    name="address"        
    class="com.foo.Address"        
    cascade="All"        
    lazy="false"/>
Java代碼
public class Order{     
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZYL)    
	Address address;
    ......	
}
						
public class Order{    
    Address address;
    ......   
}
采用annotation的優(yōu)勢(shì)在于:
  • 減少了配置文件的數(shù)量,特別是在實(shí)體(Entity)比較多的系統(tǒng)中,維護(hù)大量的O/R Mapping xml配置文件是不少的工作量。
  • 減少了配置需要標(biāo)注的內(nèi)容。由于annotation由java compiler來(lái)編譯解析,很多需要在xml配置中顯式聲明的內(nèi)容不再需要(比如變量名稱(chēng),類(lèi)型,集合中的對(duì)象類(lèi)型等)。
  • Annotation的編譯期檢查可以避免xml文件中容易出現(xiàn)的配置語(yǔ)法錯(cuò)誤,在IDE中及時(shí)發(fā)現(xiàn)和糾正。
  • 無(wú)需在xml配置文件和java代碼中切換,較少思維的跳躍,提高了開(kāi)發(fā)效率。
  • annotation被編譯到j(luò)ava bytecode中,省略了xml的解析過(guò)程,極大的提升應(yīng)用的啟動(dòng)速度和內(nèi)存占用(特別是Entity多的情況)。
JPA在啟動(dòng)上做了很多程度的簡(jiǎn)化,使我們能夠很容易地在容器內(nèi)(container)和J2SE環(huán)境中使用JPA。JPA擁有一個(gè)最基本的工廠類(lèi)EntityManagerFactory。通過(guò)調(diào)用這個(gè)工廠類(lèi)的createEntityManager()方法獲得EntityManager。所有對(duì)實(shí)體(Entity)的操作包括持久化,查詢,刪除等等操作都都定義EntityManager上。
public interface EntityManager {
    public void persist(Object entity);
    public  T merge(T entity);
    public void remove(Object entity);
    public  T find(Class entityClass, Object primaryKey);
    public  T getReference(Class entityClass, Object primaryKey);
    public void flush();
    public void setFlushMode(FlushModeType flushMode);
    public FlushModeType getFlushMode();
    public void lock(Object entity, LockModeType lockMode);
    public void refresh(Object entity);
    public void clear();
    public boolean contains(Object entity);
    public Query createQuery(String ejbqlString);
    public Query createNamedQuery(String name);
    public Query createNativeQuery(String sqlString);
    public Query createNativeQuery(String sqlString, Class result-
    Class);
    public Query createNativeQuery(String sqlString, String result-
    SetMapping);
    public void close();
    public boolean isOpen();
    public EntityTransaction getTransaction();
}
				
				

那又如何獲得EntityManagerFactory呢?不管是在J2EE或者J2SE中,都需要通過(guò)一個(gè)persistence.xml配置文件對(duì)EntityMangaerFactory進(jìn)行配置。下面是一個(gè)最簡(jiǎn)單的persistence.xml的范例。
<entity-manager>
    <name>myEntityManager>/name>
    <provider>com.redsoft.ejb3.PersistenceProviderImpl>/provider>
    <class>com.redsoft.samples.HelloEntityBean>/class>
    <properties>
        <property name="ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
        <property name="ConnectionURL" value="jdbc:mysql://localhost/EJB3Test"/>
        <property name="ConnectionUserName" value="ejb3"/>
        <property name="ConnectionPassword" value="ejb3"/>
   >/properties>
</entity-manager>

}
				
				

name – 定了當(dāng)前這個(gè)EntityMangaerFactory的名字,我們可以在一個(gè)persistence.xml中定義多個(gè)EntityManagerFactory。

Provider – 定了提供EntityManagerFactory的具體實(shí)現(xiàn)類(lèi)。這個(gè)實(shí)現(xiàn)類(lèi)由不同的持久化產(chǎn)品開(kāi)發(fā)商提供。例子中采用的是國(guó)產(chǎn)紅工場(chǎng)的ejb3持久化實(shí)現(xiàn)的 EntityManagerFactory實(shí)現(xiàn)類(lèi)。如如果我們需要更換成其他廠商的產(chǎn)品,就需要更換具體的實(shí)現(xiàn)類(lèi)。

class – 列出所有需要被JPA管理的實(shí)體類(lèi)。為了保證在J2SE/J2EE中的通用性和可移植性,JPA要求這里必須列出所有被JPA管理的實(shí)體類(lèi)。

properties – 由持久化廠商自行定義的屬性。

如果使用JTA事務(wù),也可以使用 myDataSource定義。

在J2EE容器環(huán)境中和J2SE環(huán)境中,都是通過(guò)讀取這個(gè)配置文件來(lái)初始化EntityMangaerFactory。在J2EE容器環(huán)境下,ejb3容器負(fù)責(zé)讀取persistence.xml并初始化EntityManagerFactory,并將EntityManagerFactory幫定到JDNI中,這樣我們就可以通過(guò)訪問(wèn)JNDI獲得EntityManagerFactory, 進(jìn)而獲得EntityManager。由于EJB3容器支持IOC模式,我們也可以通過(guò)IOC將EntityMangerFactory直接注射給需要的使用JPA持久化的java類(lèi)。通過(guò)IOC注射的方式獲得EntityManagerFactory或者EntityManager是更方便,合理和推薦的方式。

而在J2SE環(huán)境中,我們可以通過(guò)標(biāo)準(zhǔn)的javax.persistence.Persistence類(lèi)來(lái)獲得EntityManagerFactory。Javax.persistence.Persistence會(huì)在當(dāng)前classpath或者jar包的META-INF/下搜索并讀persistence.xml后初始化EntityManagerFactory。

下面是一個(gè)簡(jiǎn)單的示例如何在J2SE環(huán)境中獲得EntityManagerFactory并獲得EntityManager,運(yùn)用EntityManager持久化HelloWorldEntityBean.
public class HelloWorld {

    public static void main( final String[] args ){

        /*
         * Obtain an EJB3 entity manager
         */
        final EntityManagerFactory emf = Persistence.createEntityManagerFactory();
        final EntityManager entityManager = emf.createEntityManager();

        // Construct a HelloEntityBean
        final HelloEntityBean hello = new HelloEntityBean( 1, "foo" );
        EntityTransaction trans = entityManager.getTransaction();
        trans.begin();
        entityManager.persist( hello );
        trans.commit();
        System.out.println( "Successfully persist hello: " + hello );

        // Look up the HelloEntityBean by primarky key
        final HelloEntityBean anotherHello = entityManager.find( HelloEntityBean.class, new Integer( hello.getId() ) );
        System.out.println( "Found hello: " + anotherHello );

        // close the EntityManager
        entityManager.close();
        emf.close();
    }
}
				
事實(shí)上不管是在J2SE還是J2EE中我們都可以這樣通過(guò)javax.persistence.Persistence來(lái)初始化EntityManagerFactory。

在上面HelloWorld的例子中我們需要顯式調(diào)用javax.persistence.Persistence.createEntityManagerFactory, 并且顯式地開(kāi)始事務(wù)和關(guān)閉事務(wù)。在今天大量使用IOC托管容器的時(shí)代,這樣的編碼已經(jīng)顯得落后。

作為J2EE一個(gè)部分的JPA自然可以利用EJB3的IOC容器托管事務(wù)和注射資源,同樣的也可以使用開(kāi)源IOC容器spring來(lái)托管事務(wù)和注射資源。紅工場(chǎng)也提供了一個(gè)開(kāi)源的spring DAO擴(kuò)展 http://sourceforge.net/projects/ejb3daosupport 是來(lái)支持JPA和Spring的結(jié)合。

下面是一個(gè)如何在Spring中托管事務(wù)和在DAO中注入EntityManager的配置范例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "file://spring-beans.dtd">

<beans>
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
		<property name="url"><value>jdbc:mysql://localhost/EJB3Test</value></property>
		<property name="username"><value>ejb3</value></property>
		<property name="password"><value>ejb3</value></property>
	</bean>
	<bean id="entityManagerFactory"
		class="org.springframework.orm.ejb3.LocalEntityManagerFactoryBean">
		<property name="persistenceInfo"><ref local="persistenceInfo"/></property>
		
	</bean>
	<bean id="persistenceInfo" class="com.redsoft.ejb3.PersistenceInfoImpl">
		<property name="nonJtaDataSource"><ref local="dataSource"/></property>
		<property name="entityManagerName"><value>myEntityManager</value></property>
		<property name="persistenceProviderClassName">
			<value>
				com.redsoft.ejb3.PersistenceProviderImpl
			</value>
		</property>
		<property name="entityClassNames">
		<list>
			<value>com.redsoft.ejb3.spring.Child</value>
			<value>com.redsoft.ejb3.spring.Father</value>
		</list>
		</property>
		<property name="properties">
			<props>
			<prop key="javax.jdo.PersistenceManagerFactoryClass">
				com.redsoft.jdo.PersistenceManagerFactoryImpl
			</prop>
			</props>
		</property>
	</bean>
	<bean id="transactionManager" class="org.springframework.orm.ejb3.EJB3TransactionManager"
		singleton="true">
		<property name="entityManagerFactory">
			<ref local="entityManagerFactory" />
		</property>
	</bean>
	
	<bean id="dao"
		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
		singleton="true">
		<property name="transactionManager">
			<ref local="transactionManager" />
		</property>
		<property name="target">
			<bean class="com.redsoft.ejb3.spring.DAOImpl">
				<property name="entityManagerFactory">
					<ref local="entityManagerFactory" />
				</property>
			</bean>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="remove*">PROPAGATION_REQUIRED</prop>
				<prop key="del*">PROPAGATION_REQUIRED</prop>
				<prop key="update*">PROPAGATION_REQUIRED</prop>
				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
			</props>
		</property>
	</bean>
</beans>

				
文中的例子可以從紅工場(chǎng)主頁(yè)下載 http://www.redsoftfactory.com/chinese/index.html


]]>
No form found under '****Form' in locale 'zh_CN'http://www.aygfsteel.com/fine/archive/2007/01/19/94952.htmlPeter PanPeter PanFri, 19 Jan 2007 08:22:00 GMThttp://www.aygfsteel.com/fine/archive/2007/01/19/94952.htmlhttp://www.aygfsteel.com/fine/comments/94952.htmlhttp://www.aygfsteel.com/fine/archive/2007/01/19/94952.html#Feedback0http://www.aygfsteel.com/fine/comments/commentRss/94952.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/94952.htmlat org.apache.struts.taglib.html.JavascriptValidatorTag.renderJavascript(JavascriptValidatorTag.java:384)
at org.apache.struts.taglib.html.JavascriptValidatorTag.doStartTag(JavascriptValidatorTag.java:349)

<html:javascript formName="employeeForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
在validation.xml中缺少了相應(yīng)的配置
<form name="employeeForm">
????????? <field property="name" depends="required">
????????? ?<arg0 key="employeeForm.name"/>
????????? </field>
?</form>

]]>
strutsmenu使用http://www.aygfsteel.com/fine/archive/2006/10/24/77021.htmlPeter PanPeter PanTue, 24 Oct 2006 08:56:00 GMThttp://www.aygfsteel.com/fine/archive/2006/10/24/77021.htmlhttp://www.aygfsteel.com/fine/comments/77021.htmlhttp://www.aygfsteel.com/fine/archive/2006/10/24/77021.html#Feedback0http://www.aygfsteel.com/fine/comments/commentRss/77021.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/77021.html?public ActionForward execute(
???ActionMapping mapping,
???ActionForm form,
???HttpServletRequest request,
???HttpServletResponse response) {
???//創(chuàng)建連接
???Session session=SessionFactory.currentSession();
???//創(chuàng)建事務(wù)
???Transaction tx=session.beginTransaction();
???//創(chuàng)建對(duì)話
???Query query=session.createQuery("FROM Department");
???List list=query.list();
???//事務(wù)提交
???tx.commit();
???if(list.size()<0)
????return mapping.getInputForward();
???MenuRepository repository = new MenuRepository();
???HttpSession httpsession=(HttpSession)request.getSession();
???ServletContext application=(ServletContext)httpsession.getServletContext();
???MenuRepository defaultRepository = (MenuRepository)application.getAttribute(MenuRepository.MENU_REPOSITORY_KEY);
???repository.setDisplayers(defaultRepository.getDisplayers());
? ??for (int i=0; i < list.size(); i++) {
? ???MenuComponent mc = new MenuComponent();
? ???
? ???Department mi=(Department) list.get(i);
? ???
? ???String name = "a" + mi.getDepartmentCode();
???????????? mc.setName(name);
???????????? String parent = "a" + mi.getParentCode();
???????????? System.out.println(name + ", parent is: " + parent);
???????????? if(parent.equals("a0")){
???????????? ?parent = null;
???????????? }
???????????? if (parent != null) {
???????????????? MenuComponent parentMenu = repository.getMenu(parent);
???????????????? if (parentMenu == null) {
???????????????????? System.out.println("parentMenu '" + parent + "' doesn't exist!");
???????????????????? // create a temporary parentMenu
???????????????????? parentMenu = new MenuComponent();
???????????????????? parentMenu.setName(parent);
???????????????????? repository.addMenu(parentMenu);
???????????????? }
???????????????? mc.setParent(parentMenu);
???????????? }
???????????? String title = mi.getDepartmentName();
???????????? mc.setTitle(title);
????????????
??????????
???????????? mc.setLocation("index.jsp");
???????????? repository.addMenu(mc);
???}
? ??request.setAttribute("repository", repository);
???return mapping.findForward("okGo");
??}
jsp中
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="/WEB-INF/struts-menu.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/struts-menu-el.tld" prefix="menu-el" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

??? <link rel="stylesheet" type="text/css" media="all"
??????? href="<c:url value="/styles/menuExpandable.css"/>" />
?? ?
?? ? <script type="text/javascript"
??????? src="<c:url value="/scripts/menuExpandable.js"/>"></script>
??? <link rel="stylesheet" type="text/css" media="all"
??????? href="<c:url value="/styles/xtree.css"/>" />
??? <script type="text/javascript"
??????? src="<c:url value="/scripts/xtree.js"/>"></script>
???????
??? <link rel="stylesheet" type="text/css" media="screen"
??????? href="<c:url value="/styles/global.css"/>" />
???????
???????
??? <script type="text/javascript">
??????? /* Function for showing and hiding elements that use 'display:none' to hide */
??????? function toggleDisplay(targetId) {
??????????? if (document.getElementById) {
??????????????? target = document.getElementById(targetId);
??????????????? if (target.style.display == "none"){
??????????????????? target.style.display = "";
??????????????? } else {
??????????????????? target.style.display = "none";
??????????????? }
??????????? }
??????? }
??? </script>
?? <!--
??? <div class="dynamicMenu tree">
??????? <menu:useMenuDisplayer name="ListMenu" repository="repository">
??????????? <menu:displayMenu name="a01"/>
??????????? <menu:displayMenu name="a02"/>
??????? </menu:useMenuDisplayer>
??? </div>
???
??? <div class="dynamicMenu tree">
??? <script type="text/javascript">
??????? <menu:useMenuDisplayer name="Velocity" config="/templates/xtree.html"
??????????? repository="repository">
????????? <c:forEach var="menu" items="${repository.topMenus}">
??????????? <menu-el:displayMenu name="${menu.name}"/>
????????? </c:forEach>
??????? </menu:useMenuDisplayer>
??? </script>
??? </div>
??? -->
?<div id="content">
?<script type="text/javascript" src="<c:url value="/scripts/coolmenus3.js"/>"></script>
?<script type="text/javascript" src="<c:url value="/scripts/coolmenu-config.js"/>"></script>
??????? <menu:useMenuDisplayer name="CoolMenu"? repository="repository">
??????????? <menu:displayMenu name="a01"/>
??????????? <menu:displayMenu name="a02"/>
??????? </menu:useMenuDisplayer>
??? </div>
menu-config.xml
<?xml version="1.0" encoding="UTF-8" ?>

<MenuConfig>

? <Displayers>
??? <Displayer?? name="DropDown"
???????????????? type="net.sf.navigator.displayer.DropDownMenuDisplayer"/>
??? <Displayer?? name="Simple"
???????????????? type="net.sf.navigator.displayer.SimpleMenuDisplayer"/>
??? <Displayer?? name="CoolMenu"
???????????????? type="net.sf.navigator.displayer.CoolMenuDisplayer"/>
??? <Displayer?? name="CoolMenu4"
???????????????? type="net.sf.navigator.displayer.CoolMenuDisplayer4"/>
??? <Displayer?? name="MenuForm"
???????????????? type="net.sf.navigator.example.PermissionsFormMenuDisplayer"/>
??? <Displayer?? name="ListMenu"
???????????????? type="net.sf.navigator.displayer.ListMenuDisplayer"/>
??? <Displayer?? name="TabbedMenu"
???????????????? type="net.sf.navigator.displayer.TabbedMenuDisplayer"/>
??? <Displayer?? name="Velocity"
???????????????? type="net.sf.navigator.displayer.VelocityMenuDisplayer"/>
? </Displayers>

? <Menus>
?
? </Menus>

</MenuConfig>



]]>
xdoclet1.2.3&xdoclet2http://www.aygfsteel.com/fine/archive/2006/09/27/72349.htmlPeter PanPeter PanWed, 27 Sep 2006 09:30:00 GMThttp://www.aygfsteel.com/fine/archive/2006/09/27/72349.htmlhttp://www.aygfsteel.com/fine/comments/72349.htmlhttp://www.aygfsteel.com/fine/archive/2006/09/27/72349.html#Feedback0http://www.aygfsteel.com/fine/comments/commentRss/72349.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/72349.html用xdoclet 和xdoclet2來(lái)產(chǎn)生hiberante map文件的一些區(qū)別
xdoclet升級(jí)到1.2.3了,文檔上說(shuō)是支持hibernate 3了,實(shí)際上,經(jīng)過(guò)今天的檢驗(yàn),發(fā)現(xiàn)xdoclet 1.2.3只是支持hibernate 3的map文件了,而生成的hibernate 3的config文件,卻還hibernate 2的。
?
一個(gè)簡(jiǎn)單的例子(就是這個(gè)例子:ttp://www.redsaga.com/hibernate-ref/3.1.2/zh-cn/html/tutorial.html#tutorial-firstapp-firstclass,按它上面的介紹,設(shè)置好各個(gè)目錄結(jié)構(gòu)):
package events;
import java.util.Date;
/**
?*
?* @hibernate.class table="EVENTS"
?*/
public class Event {

??? private Long id;
??? private String title;
??? private Date date;
??? public Event() {
??? }
??? /**
???? * @hibernate.id
???? * generator-class="uuid.hex"
???? * type="java.lang.String"
???? * unsaved-value=""
???? * column="EVENT_ID"
???? */
??? public Long getId() {
??????? return id;
??? }
??? private void setId(Long id) {
??????? this.id = id;
??? }
??? /**
???? * @hibernate.property
???? * column="EVENT_DATE"
???? * type = "timestamp"
???? *
???? *
???? */
??? public Date getDate() {
??????? return date;
??? }
??? public void setDate(Date date) {
??????? this.date = date;
??? }
??? /**
???? * @hibernate.property
???? * column="EVENT_TITLE"
???? * length="20"
???? *
???? */
??? public String getTitle() {
??????? return title;
??? }
??? public void setTitle(String title) {
??????? this.title = title;
??? }
}
?
上面的POJO,已經(jīng)加上了xdoclet的javadoc tag了,現(xiàn)在用下面的ant文件來(lái)產(chǎn)生map和config文件:
?
<project name="xdoclet" default="hibernatedoclet">
??? <property name="sourcedir" value="${basedir}/src"/>
??? <property name="targetdir" value="${basedir}/bin"/>
??? <property name="librarydir" value="${basedir}/lib"/>
??? <path id="libraries">
??????? <fileset dir="${librarydir}">
??????????? <include name="*.jar"/>
??????? </fileset>
??? </path>
??? <target name="clean">
??????? <delete dir="${targetdir}"/>
??????? <mkdir dir="${targetdir}"/>
??? </target>
??? <target name="compile" depends="clean, copy-resources">
??????? <javac srcdir="${sourcedir}"
?????????????? destdir="${targetdir}"
?????????????? classpathref="libraries"/>
??? </target>
??? <target name="copy-resources">
??????? <copy todir="${targetdir}">
??????????? <fileset dir="${sourcedir}">
??????????????? <exclude name="**/*.java"/>
??????????? </fileset>
??????? </copy>
??? </target>
??? <taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
?????? <classpath>
???????????? <fileset dir="E:/workspace/xdoclet-1.2.3/lib" includes="*.jar"/>
??????? </classpath>
??? </taskdef>
??? <target name="hibernate" depends="compile" description="Generate mapping documents">
????????? <hibernatedoclet
??????????????? destdir="${targetdir}"
??????????????? excludedtags="@version,@author,@todo,@see"
??????????????? force="false"
??????????????? verbose="true">
??????????????? <fileset dir="${sourcedir}">
??????????????????? <include name="**/*.java"/>
??????????????? </fileset>
??????????????? <hibernatecfg
??????????????????????? dialect="net.sf.hibernate.dialect.xxxxx"
??????????????????????? driver="com.mysql.jdbc.Driver"
??????????????????????? jdbcUrl="jdbc:mysql://xxxxx"
??????????????????????? userName="xxxxx"
??????????????????????? password="xxxxx"/>
???????????????????????
???????????????? <hibernate version="3.0"/>
??????????? </hibernatedoclet>
??????? </target>
</project>
?
結(jié)果如下:
Event.hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
??? "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
??? "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
??? <class
??????? name="events.Event"
??????? table="EVENTS"
??? >
??????? <id
??????????? name="id"
??????????? column="EVENT_ID"
??????????? type="java.lang.String"
??????????? unsaved-value=""
??????? >
??????????? <generator class="uuid.hex">
????????????? <!--?
????????????????? To add non XDoclet generator parameters, create a file named
????????????????? hibernate-generator-params-Event.xml
????????????????? containing the additional parameters and place it in your merge dir.
????????????? -->
??????????? </generator>
??????? </id>
??????? <property
??????????? name="date"
??????????? type="timestamp"
??????????? update="true"
??????????? insert="true"
??????????? column="EVENT_DATE"
??????? />
??????? <property
??????????? name="title"
??????????? type="java.lang.String"
??????????? update="true"
??????????? insert="true"
??????????? column="EVENT_TITLE"
??????????? length="20"
??????? />
??????? <!--
??????????? To add non XDoclet property mappings, create a file named
??????????????? hibernate-properties-Event.xml
??????????? containing the additional properties and place it in your merge dir.
??????? -->
??? </class>
</hibernate-mapping>
hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<!-- Generated file - Do not edit! -->
<hibernate-configuration>
?<!-- a SessionFactory instance listed as /jndi/name -->
?<session-factory>
??<!-- properties -->
??<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
??<property name="show_sql">false</property>
??<property name="use_outer_join">false</property>
???<property name="connection.username">hibernate</property>
???<property name="connection.password">aPassword</property>
???<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
???<property name="connection.url">jdbc:mysql://xxx</property>
??<!-- mapping files -->
??<mapping resource="events/Event.hbm.xml"/>
?</session-factory>
</hibernate-configuration>
發(fā)現(xiàn)沒(méi)有,上面的config文件中的DTD版本還是2.0。
?

對(duì)于hibernate3來(lái)說(shuō),現(xiàn)在多了個(gè)選擇,用xdoclet2也可以產(chǎn)生map文件,但是config文件好像沒(méi)有辦法。
還是用上面POJO,對(duì)應(yīng)的ant文件如下(注意,簡(jiǎn)單起見(jiàn),要把xdoclet2下面的lib目錄下的jar文件,全部copy到${basedir}/lib下):
<project name="xdoclet2-plugin" default="hibernatedoclet">
??? <property name="sourcedir" value="${basedir}/src"/>
??? <property name="targetdir" value="${basedir}/bin"/>
???? <property name="librarydir" value="${basedir}/lib"/>
?
??? <path id="libraries">
??????? <fileset dir="${librarydir}">
??????????? <include name="*.jar"/>
??????? </fileset>
??? </path>
??? <target name="clean">
??????? <delete dir="${targetdir}"/>
??????? <mkdir dir="${targetdir}"/>
??? </target>
??? <target name="compile" depends="clean, copy-resources">
??????? <javac srcdir="${sourcedir}"
?????????????? destdir="${targetdir}"
?????????????? classpathref="libraries"/>
??? </target>
??? <target name="copy-resources">
??????? <copy todir="${targetdir}">
??????????? <fileset dir="${sourcedir}">
??????????????? <exclude name="**/*.java"/>
??????????? </fileset>
??????? </copy>
??? </target>
??? <target name="hibernatedoclet"
??????????? depends="compile"
??????????? description="Generate Persistence and form classes">
??????????? <taskdef
??????????????? name="xdoclet"
??????????????? classname="org.xdoclet.ant.XDocletTask"
??????????????? classpathref="libraries"
??????????????? />
??????????? <xdoclet>
??????????????? <!-- defines the file handled by xdoclet2 -->
??????????????? <fileset dir="${sourcedir}">
??????????????????? <include name="**/*.java"/>
??????????????? </fileset>
??????????????? <!-- defines the processing of a plugin -->
??????????????? <component
??????????????????? classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
??????????????????? destdir="${targetdir}"
??????????????????? version="3.0"
??????????????????? />
??????????? </xdoclet>
??????? </target>

</project>
?
結(jié)果如下:
Event.hbm.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
? <class table="EVENTS" name="events.Event">
??? <id type="java.lang.String" column="EVENT_ID" unsaved-value="" access="method" name="id">
????? <generator class="uuid.hex"/>
??? </id>
??? <property name="date" type="timestamp" access="method" column="EVENT_DATE"/>
??? <property name="title" length="20" access="method" column="EVENT_TITLE"/>
? </class>
</hibernate-mapping>
發(fā)現(xiàn)用xdoclet1.2.3和xdoclet2產(chǎn)生的map文件還是有些區(qū)別的,包括形式和內(nèi)容,也許那些區(qū)別都無(wú)所謂,但是畢竟有不同。從形式來(lái)看,明星xdoclet2產(chǎn)生的文件好看些,所以,以后,我看還是應(yīng)該用xdoclet2來(lái)產(chǎn)生map文件。config文件,就手寫(xiě)吧。
?

?
應(yīng)用?xdoclet1.2.3和xdoclet2,要注意的最大的一點(diǎn)是:POJO的javadoc tag中的所有@hibernate.collection-xxxxx都已經(jīng)改變成@hibernate.xxxx了。所以,對(duì)已有的POJO應(yīng)用xdoclet2時(shí),可能要做個(gè)簡(jiǎn)單的替換工作。


]]>
java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPasshttp://www.aygfsteel.com/fine/archive/2006/08/10/62715.htmlPeter PanPeter PanThu, 10 Aug 2006 01:23:00 GMThttp://www.aygfsteel.com/fine/archive/2006/08/10/62715.htmlhttp://www.aygfsteel.com/fine/comments/62715.htmlhttp://www.aygfsteel.com/fine/archive/2006/08/10/62715.html#Feedback1http://www.aygfsteel.com/fine/comments/commentRss/62715.htmlhttp://www.aygfsteel.com/fine/services/trackbacks/62715.htmljava.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
Problem with Spring 1.2.6 and Hibernate 3.1 : HbmBinder$SecondPass

今天又遇到了這個(gè)問(wèn)題,真是讓人郁悶了老半天。一心揪出它的根本原因,經(jīng)過(guò)了好半天的刺撓終于找到了就是(hibernate3.jar和hibernate-annotations.jar)的問(wèn)題,簡(jiǎn)單主法把hibernate-annotations.jar直接干掉就OK了。
好果有用到這個(gè)包就得去找個(gè)高點(diǎn)version的去用了。
不知道大家有沒(méi)有更好的解決方法呀

Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader .java:260)
at java.net.URLClassLoader.access$100(URLClassLoader. java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
at org.hibernate.cfg.Configuration.add(Configuration. java:385)
at org.hibernate.cfg.Configuration.addInputStream(Con figuration.java:426)
at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:654)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:269)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
at org.stockfi.persistence.orm.hibernate.core.Main.ma in(Main.java:57)
?
?
reason is:It seems that org\hibernate\cfg\HbmBinder$SecondPass.class no longer exists in hibernate3.jar.
Specifically, the hibernate3.jar that ships with Spring 1.2.7 appears to be Hibernate v3.0.5. This version of the jar does indeed include the org/hibernate/cfg/HbmBinder$SecondPass class. When I remove this version of hibernate3.jar and replace it with the latest and greatest hibernate3.jar this problem arises. The latest version of Hibernate (hibernate3.jar) is v3.1.3.

By simply inspecting the contents of the hibernate3.jar files you will see this problem.

This leads me to believe that we must use the hibernate3.jar that ships with Spring v.1.2.7 (or whatever version people are using with respect to 1.2.x).

My immediate concern is that itermixing Hibernate 3.1.3 support/dependency jars with a v3.0.5 hibernate3.jar may cause issues. I suppose I will need to download and use Hibernate 3.0.5 to be safe but I'd like very much to use Hibernate 3.1.3 w/o concern.

Any ideas on whether a patch/update will be made available to get around this issue.

?
See if there's been any issue raised on this topic. I know this topic has been discussed several times but always the solution was using the proper jars (and eliminating old ones which were used as dependencies as already noted in this thread).
I've used spring with HB 3.1.3 and 3.0.5 without problems and by looking at the stacktrace, the problem is with hibernate (which actually calls the missing class) and not with Spring.


]]>
主站蜘蛛池模板: 定结县| 长丰县| 新龙县| 柳河县| 武强县| 广宗县| 清镇市| 邳州市| 淅川县| 喜德县| 中西区| 密山市| 清镇市| 左云县| 慈溪市| 木兰县| 邓州市| 方正县| 青河县| 涿州市| 武隆县| 随州市| 安义县| 苗栗市| 云浮市| 怀宁县| 赤城县| 敦煌市| 新安县| 清徐县| 昌乐县| 兴海县| 会昌县| 兴仁县| 中超| 南阳市| 三穗县| 汉阴县| 灵寿县| 鄂伦春自治旗| 邯郸县|