<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    關(guān)于JSF1.2 + Spring2.5 + Hibernate3 + Facelets + Annotation整合配置的參考。

        提供一個(gè)整合JSF,Spring, Hibernate(JPA), Facelets, 及Annotation的基礎(chǔ)環(huán)境。對(duì)于剛開(kāi)始使用這種組合的項(xiàng)目,或許可以參考一下,相信使用以上整合環(huán)境的項(xiàng)目還是比較少。我一直很喜歡這種組合,JSF組件式的開(kāi)發(fā),Spring, Hibernate對(duì)BackingBean及數(shù)據(jù)源的管理,F(xiàn)acelets的模版化技術(shù),以及Annotation都大大簡(jiǎn)化了開(kāi)發(fā)。
        JSF組件的高度封裝及高可重用性,使得頁(yè)面代碼在非常簡(jiǎn)單的情況下快速實(shí)現(xiàn)非常復(fù)雜的功能。Spring,Hibernate的整合進(jìn)一步簡(jiǎn)化了JSF的開(kāi)發(fā),特別是Annotation的配置使得現(xiàn)在幾乎完全不需要去XML中配置Bean這些繁瑣的事情,這確實(shí)很繁瑣,特別是如果再加上配置JSF的導(dǎo)航規(guī)則,在開(kāi)發(fā)過(guò)程中經(jīng)常要去碰這些東西,確實(shí)很麻煩,又容易出錯(cuò)。所以如果項(xiàng)目允許,還是推薦使用Annotation,并且這也是很多專家推薦的。作為Java5新加入的特性,它確實(shí)對(duì)開(kāi)發(fā)帶來(lái)了很大的方便,以前不怎么喜歡,不過(guò)現(xiàn)在感覺(jué)它很有前途!另一個(gè)就是Facelets了,這可是用來(lái)替代JSP的視圖描述技術(shù),F(xiàn)acelets模版化的威力可是非常強(qiáng)大,雖然不少人認(rèn)為它的自定義標(biāo)簽功能更強(qiáng)大,具體介紹還是大家網(wǎng)上搜一下吧。下面看一下大概的配置過(guò)程,僅供參考,因?yàn)榫W(wǎng)上也有不少類似的教程,所以不作啰嗦,僅取重點(diǎn)。

    環(huán)境:Netbeans7, Tomcat6.0.18, MySQL5

    相關(guān)框架:JSF1.2,Spring2.5,Hibernate3(JPA), Facelets, Annotation, MyFaces(附加), QFaces(附加)

    1.相關(guān)引用的jar包

    可以看到引用的jar還是不少,至少加起來(lái)有43.2M。最后一個(gè)是我自定義的組件包qfaces-1.2.1,剛升級(jí)支持Facelets(qfaces在1.2及之前未能夠支持Facelets而沒(méi)有說(shuō)明,使一些用Facelets的朋友遇到麻煩,這里道歉哦。)

    2.web.xml文件配置
      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      3     <context-param>
      4         <param-name>com.sun.faces.verifyObjects</param-name>
      5         <param-value>false</param-value>
      6     </context-param>
      7     <context-param>
      8         <param-name>com.sun.faces.validateXml</param-name>
      9         <param-value>true</param-value>
     10     </context-param>
     11     <context-param>
     12         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
     13         <param-value>client</param-value>
     14     </context-param>
     15 
     16     <!-- Config:Facelets -->
     17 
     18     <context-param>
     19         <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
     20         <param-value>.xhtml</param-value>
     21     </context-param>
     22 
     23     <!-- Config:Spring -->
     24 
     25     <servlet>
     26         <servlet-name>dispatcher</servlet-name>
     27         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     28         <load-on-startup>2</load-on-startup>
     29     </servlet>
     30     <servlet-mapping>
     31         <servlet-name>dispatcher</servlet-name>
     32         <url-pattern>*.htm</url-pattern>
     33     </servlet-mapping>
     34     <listener>
     35         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     36     </listener>
     37     <listener>
     38         <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
     39     </listener>
     40     <listener>
     41         <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
     42     </listener>
     43     <listener>
     44         <listener-class>com.sun.faces.application.WebappLifecycleListener</listener-class>
     45     </listener>
     46 
     47     <!-- Config:MyFaces -->
     48 
     49     <filter>
     50         <filter-name>MyFacesExtensionsFilter</filter-name>
     51         <filter-class>
     52             org.apache.myfaces.webapp.filter.ExtensionsFilter
     53         </filter-class>
     54         <init-param>
     55             <param-name>uploadMaxFileSize</param-name>
     56             <param-value>100m</param-value>
     57         </init-param>
     58         <init-param>
     59             <param-name>uploadThresholdSize</param-name>
     60             <param-value>80k</param-value>
     61         </init-param>
     62     </filter>
     63     <filter-mapping>
     64         <filter-name>MyFacesExtensionsFilter</filter-name>
     65         <servlet-name>Faces Servlet</servlet-name>
     66     </filter-mapping>
     67     <filter-mapping>
     68         <filter-name>MyFacesExtensionsFilter</filter-name>
     69         <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
     70     </filter-mapping>
     71 
     72     <!-- Config:QFaces -->
     73 
     74     <servlet>
     75         <servlet-name>QFaces</servlet-name>
     76         <servlet-class>name.huliqing.qfaces.FacesServlet</servlet-class>
     77     </servlet>
     78     <servlet-mapping>
     79         <servlet-name>QFaces</servlet-name>
     80         <url-pattern>*.qfaces</url-pattern>
     81     </servlet-mapping>
     82 
     83     <!-- End -->
     84 
     85     <servlet>
     86         <servlet-name>Faces Servlet</servlet-name>
     87         <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     88         <load-on-startup>1</load-on-startup>
     89     </servlet>
     90     <servlet-mapping>
     91         <servlet-name>Faces Servlet</servlet-name>
     92         <url-pattern>*.faces</url-pattern>
     93     </servlet-mapping>
     94     <session-config>
     95         <session-timeout>
     96             30
     97         </session-timeout>
     98     </session-config>
     99     <welcome-file-list>
    100         <welcome-file>welcome.jsp</welcome-file>
    101     </welcome-file-list>
    102     </web-app>
    103 
    這是web.xml,可以看到默認(rèn)的配置很簡(jiǎn)單,并沒(méi)有什么特別的,在網(wǎng)上大都可以看到類似。相關(guān)部分都有注識(shí)。上面Facelets配置的默認(rèn)后綴就是xhtml了,這樣當(dāng)我們?cè)L問(wèn)如 test.faces這樣的頁(yè)面時(shí),就會(huì)由Facelets的ViewHandler最后解析到test.xhtml。所以我們的頁(yè)面后綴就需要是.xhtml。另外兩個(gè)額外的配置MyFaces,QFaces,如果不需要,都可以直接注釋掉,不會(huì)影響。

    3.faces-config.xml
    文件位置: WEB-INF/faces-config.xml
     1 <?xml version='1.0' encoding='UTF-8'?>
     2 
     3 <!-- =========== FULL CONFIGURATION FILE ================================== -->
     4 
     5 <faces-config version="1.2" 
     6     xmlns="http://java.sun.com/xml/ns/javaee" 
     7     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     8     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
     9     <application>
    10         <!-- 國(guó)際化支持 -->
    11         <locale-config>
    12             <default-locale>zh</default-locale>
    13             <supported-locale>zh</supported-locale>
    14             <supported-locale>en</supported-locale>
    15         </locale-config>
    16         <message-bundle>resource</message-bundle>
    17         <resource-bundle>
    18             <base-name>resource</base-name>
    19             <var>text</var>
    20         </resource-bundle>
    21         <!-- Facelet, Spring -->
    22         <view-handler>
    23             com.sun.facelets.FaceletViewHandler
    24         </view-handler>
    25         <variable-resolver>
    26             org.springframework.web.jsf.DelegatingVariableResolver
    27         </variable-resolver>
    28     </application>
    29 </faces-config>
    重點(diǎn)注意Facelets view-handler及Spring variable-resolver的配置就可以。

    4.dispatcher-servlet.xml
    文件位置:WEB-INF/dispatcher-servlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:p
    ="http://www.springframework.org/schema/p"
           xmlns:aop
    ="http://www.springframework.org/schema/aop"
           xmlns:tx
    ="http://www.springframework.org/schema/tx"
           xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
    >
        
        
    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
       

        
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            
    <property name="mappings">
                
    <props>
                    
    <prop key="/index.htm">indexController</prop>
                
    </props>
            
    </property>
        
    </bean>
        
        
    <bean id="viewResolver"
              class
    ="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix
    ="/WEB-INF/jsp/"
              p:suffix
    =".jsp" />
       

        
    <bean name="indexController"
              class
    ="org.springframework.web.servlet.mvc.ParameterizableViewController"
              p:viewName
    ="index" />
        
    </beans>
    這也是Spring的默認(rèn)配置

    5.applicationContext.xml
    文件位置:WEB-INF/applicationContext.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:p
    ="http://www.springframework.org/schema/p"
           xmlns:aop
    ="http://www.springframework.org/schema/aop"
           xmlns:tx
    ="http://www.springframework.org/schema/tx"
           xmlns:context
    ="http://www.springframework.org/schema/context"
           xsi:schemaLocation
    ="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop 
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx 
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd"
    >
        
    <aop:aspectj-autoproxy/>
        
    <context:annotation-config/>
        
    <context:component-scan base-package="name.huliqing.magic"/>
        
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            
    <property name="location" value="classpath:jdbc.properties"/>
        
    </bean>
        
    <bean id="_data_source" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
            
    <property name="url" value="${jdbc.url}"/>
            
    <property name="username" value="${jdbc.username}"/>
            
    <property name="password" value="${jdbc.password}"/>
        
    </bean>
        
    <alias name="_data_source" alias="dataSource"/>
        
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            
    <property name="persistenceUnitName" value="SpringJPADbUnit"/>
            
    <property name="dataSource" ref="dataSource"/>
            
    <property name="jpaVendorAdapter">
                
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    
    <property name="databasePlatform" value="${jdbc.dialect}"/>
                    
    <property name="showSql" value="${jdbc.showSql}"/>
                    
    <property name="generateDdl" value="${jdbc.generateDdl}"/>
                
    </bean>
            
    </property>
        
    </bean>
        
    <bean id="jDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/> 
        
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
            
    <property name="dataSource" ref="dataSource"/>
            
    <property name="jpaDialect" ref="jDialect"/>
        
    </bean>
        
    <tx:annotation-driven transaction-manager="transactionManager"/>
    </beans>

    <aop:aspectj-autoproxy/> 提供對(duì)AspectJ的支持
    <context:annotation-config/> 提供對(duì)annotation的支持
    <context:component-scan base-package="name.huliqing.magic"/> 指定需要被Spring進(jìn)行掃描的類包,base-package下的類及子包都會(huì)被掃描以提供依賴注入,注意修改為自己的包名。
    <tx:annotation-driven transaction-manager="transactionManager"/> 對(duì)Annotation進(jìn)行事務(wù)管理的支持。
    其它定義的一些bean主要是對(duì)數(shù)據(jù)源的配置,更詳細(xì)的信息請(qǐng)查閱相關(guān)的資料。

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            
    <property name="location" value="classpath:jdbc.properties"/>
    </bean>
    注意這里指定了數(shù)據(jù)源配置文件的位置classpath:jdbc.properties.

    6.jdbc.properties

    文件位置 classpath:jdbc.properties
    jdbc.dialect = org.hibernate.dialect.MySQLDialect
    jdbc.driverClassName 
    = com.mysql.jdbc.Driver
    jdbc.url 
    = jdbc:mysql://localhost:3306/magic?characterEncoding=UTF-8
    jdbc.username = root
    jdbc.password 
    =
    jdbc.showSql 
    = false
    jdbc.generateDdl 
    = false

    上面是jdbc文件的配置內(nèi)容,下面顯示了文件的位置,同時(shí)顯示了Spring的兩個(gè)配置文件的位置。


    上面提供了對(duì)數(shù)據(jù)庫(kù)的連接信息,數(shù)據(jù)庫(kù)magic,用戶root,密碼空。基本上JSF+Spring+Hibernate+Facelets就是這個(gè)配置了。
    下面為了測(cè)試環(huán)境,將在magic庫(kù)中創(chuàng)建一個(gè)數(shù)據(jù)表test,并創(chuàng)建一些相應(yīng)的類,進(jìn)行測(cè)試一下。

    7.測(cè)試環(huán)境

    首先創(chuàng)建一個(gè)數(shù)據(jù)表magic.test
    DROP TABLE IF EXISTS magic.test;

    CREATE database IF NOT EXISTS magic DEFAULT charset utf8 COLLATE utf8_general_ci;

    use magic;

    create table magic.test (
        num 
    int not null auto_increment,
        id 
    varchar(32not null,
        password 
    varchar(64not null,
        des 
    varchar(64not null,
        
    primary key  (num)
    ) engine 
    = InnoDB default charset = utf8;

    接下來(lái)將創(chuàng)建以下東東:
    Dao.java - Dao接口:
    DaoBase.java - Dao基類,實(shí)現(xiàn)Dao.java的接口

    TestDa.java - Dao,繼承DaoBase.java
    TestEn.java - Entity,持久化類,對(duì)應(yīng)數(shù)據(jù)表magic.test
    TestSe.java - Service,業(yè)務(wù)邏輯層
    TestWe.java - BackingBean
    test.xhtml  - 測(cè)試頁(yè)面

    下面是目錄結(jié)構(gòu),因?yàn)檫@是測(cè)試,所以我并沒(méi)有把它們放在相應(yīng)的目錄。其它幾個(gè)類可以不管。


    下面是各個(gè)類的代碼:
    TestEn.java
    package name.huliqing.magic.test;

    import java.io.Serializable;
    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.Table;

    @Entity
    @Table(name 
    = "test")
    @NamedQueries({})
    public class TestEn implements Serializable {
        
    private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue
        @Basic(optional 
    = false)
        @Column(name 
    = "num")
        
    private Integer num;
        @Basic(optional 
    = false)
        @Column(name 
    = "id")
        
    private String id;
        @Basic(optional 
    = false)
        @Column(name 
    = "password")
        
    private String password;
        @Basic(optional 
    = false)
        @Column(name 
    = "des")
        
    private String des;

        
    public TestEn() {
        }

        
    public TestEn(Integer num) {
            
    this.num = num;
        }

        
    public TestEn(Integer num, String id, String password, String des) {
            
    this.num = num;
            
    this.id = id;
            
    this.password = password;
            
    this.des = des;
        }

        
    public Integer getNum() {
            
    return num;
        }

        
    public void setNum(Integer num) {
            
    this.num = num;
        }

        
    public String getId() {
            
    return id;
        }

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

        
    public String getPassword() {
            
    return password;
        }

        
    public void setPassword(String password) {
            
    this.password = password;
        }

        
    public String getDes() {
            
    return des;
        }

        
    public void setDes(String des) {
            
    this.des = des;
        }

        @Override
        
    public int hashCode() {
            
    int hash = 0;
            hash 
    += (num != null ? num.hashCode() : 0);
            
    return hash;
        }

        @Override
        
    public boolean equals(Object object) {
            
    // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof TestEn)) {
                
    return false;
            }
            TestEn other 
    = (TestEn) object;
            
    if ((this.num == null && other.num != null|| (this.num != null && !this.num.equals(other.num))) {
                
    return false;
            }
            
    return true;
        }

        @Override
        
    public String toString() {
            
    return "name.huliqing.magic.domain.TestEn[num=" + num + "]";
        }

    }
    這個(gè)Entity是Netbeans通過(guò)數(shù)據(jù)表magic.test生成的代碼,相關(guān)的注解都看到了,不明白的可以查閱一下相關(guān)資料

    接口Dao.java
    package name.huliqing.magic.dao;

    import java.io.Serializable;

    public interface Dao<T, PK extends Serializable>{

        
    public T save(final T t);

        
    public T update(final T t);

        
    public void delete(final T t);

        
    public T find(final PK id);
    }

    基類:BaseDao.java
    package name.huliqing.magic.dao;

    import java.io.Serializable;
    import java.util.List;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.PersistenceUnit;
    import javax.persistence.Query;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.jdbc.datasource.DriverManagerDataSource;
    import org.springframework.orm.jpa.JpaTemplate;

    public class DaoBase<T, PK extends Serializable> implements Dao<T, PK>{

        
    protected Class<T> type;
        
    protected JpaTemplate jpaTemplate;
        
    protected EntityManagerFactory entityManagerFactory;
        
    protected DriverManagerDataSource dateSource;

        
    public DaoBase(Class<T> type) {
            
    this.type = type;
        }

        @PersistenceUnit
        
    public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
            
    this.entityManagerFactory = entityManagerFactory;
            
    this.jpaTemplate = new JpaTemplate(entityManagerFactory);
        }

        @Autowired
        
    public void setDataSource(DriverManagerDataSource dateSource) {
            
    this.dateSource = dateSource;
        }

        
    public T save(T t) {
            
    this.jpaTemplate.persist(t);
            
    this.jpaTemplate.flush();
            
    return t;
        }

        
    public T update(T t) {
            
    this.jpaTemplate.merge(t);
            
    this.jpaTemplate.flush();
            
    return t;
        }

        
    public void delete(T t) {
            T _o 
    = this.jpaTemplate.merge(t);
            
    this.jpaTemplate.remove(_o);
            
    this.jpaTemplate.flush();
        }

        
    public T find(PK id) {
            
    return (T) this.jpaTemplate.find(type, id);
        }

        
    public List<T> findByObject(T t, String fuzzy) {
            EntityManagerFactory emf 
    = this.jpaTemplate.getEntityManagerFactory();
            EntityManager em 
    = emf.createEntityManager();
            Query q 
    = DaoQueryMake.makeQuery(em, t, fuzzy);
            List
    <T> result = q.getResultList();
            
    return result;
        }
    }
    Dao.java, DaoBase.java都使用了泛型,
    Dao.java主要定義了相關(guān)的基本接口,
    DaoBase.java主要提供了Spring對(duì)數(shù)據(jù)源的注入及管理,同時(shí)實(shí)現(xiàn)了Dao.java的接口,這樣其它Dao只要繼承自DaoBase.java就可以毫不費(fèi)勁的獲得幾個(gè)很基本的功能:save, update, delete, find

    測(cè)試類Dao: TestDa.java
    package name.huliqing.magic.test;

    import name.huliqing.magic.dao.*;
    import org.springframework.stereotype.Component;

    @Component
    public class TestDa extends DaoBase{

        
    public TestDa() {
            
    super(TestEn.class);
        }
    }

    測(cè)試類Service: TestSe.java
    package name.huliqing.magic.test;

    import java.util.List;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;
    import org.springframework.transaction.annotation.Transactional;

    @Component
    public class TestSe {

        @Autowired
        private TestDa testDa;

        @Transactional
        public TestEn save(TestEn testEn) {
            return (TestEn) testDa.save(testEn);
        }

        @Transactional
        public TestEn update(TestEn testEn) {
            return (TestEn) testDa.update(testEn);
        }

        @Transactional
        public void delete(TestEn testEn) {
            testDa.delete(testEn);
        }

        public List<TestEn> findByObject(Object o, String... fuzzy) {
            return testDa.findByObject(o, fuzzy);
        }
    }

    測(cè)試類Backing: TestWe.java
    package name.huliqing.magic.test;

    import name.huliqing.magic.Message;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;

    @Component
    @Scope(
    "request")
    public class TestWe implements java.io.Serializable{

        @Autowired
        
    private TestSe testSe;
        
    private TestEn testEn;

        
    public TestWe() {
            
    this.testEn = new TestEn();
        }

        
    public TestEn getTestEn() {
            
    return testEn;
        }

        
    public void setTestEn(TestEn testEn) {
            
    this.testEn = testEn;
        }

        
    public void save() {
            TestEn _testEn 
    = testSe.save(testEn);
            
    if (_testEn != null) {
                Message.addInfoMessage(
    "注冊(cè)成功");
            }
        }
    }
    看一下幾個(gè)Test類,主要用到幾個(gè)注解:@Component @Autowired @Transactional
    @Component 標(biāo)明了獲得Spring管理的Bean, 默認(rèn)名稱為類名的首字母小寫(xiě),主要注意Component的保存scope。
    @Autowired 實(shí)現(xiàn)Bean的快速注入。
    @Transactional,通過(guò)這個(gè)注解,方法將自動(dòng)獲得事務(wù)支持。

    下面是測(cè)試頁(yè)面:test.xhtml
     1 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
     2         xmlns:h="http://java.sun.com/jsf/html"
     3         xmlns:f="http://java.sun.com/jsf/core"
     4         xmlns:t="http://myfaces.apache.org/tomahawk"
     5         xmlns:ui="http://java.sun.com/jsf/facelets"
     6         template="/WEB-INF/layout/template.xhtml">
     7     <ui:define name="content">
     8         <ui:insert name="messages">
     9             <h:messages globalOnly="true" showDetail="true" infoClass="colorGreen" errorClass="colorRed" fatalClass="colorOrange"/>
    10         </ui:insert>
    11         <h:form>
    12         <h:panelGrid columns="3" styleClass="border">
    13             <h:outputText value="用戶ID" />
    14             <h:inputText id="id" value="#{testWe.testEn.id}" />
    15             <h:outputText value="請(qǐng)?zhí)顚?xiě)你的ID" />
    16 
    17             <h:outputText value="設(shè)置密碼" />
    18             <h:inputSecret id="password" value="#{testWe.testEn.password}" />
    19             <h:outputText value="建議由字母與數(shù)字混合組成" />
    20 
    21             <h:outputText value="個(gè)人說(shuō)明" />
    22             <h:inputTextarea id="des" value="#{testWe.testEn.des}" />
    23             <h:outputText value="個(gè)人的一些備注" />
    24 
    25             <h:panelGroup />
    26             <h:commandButton value="申請(qǐng)" action="#{testWe.save}" />
    27             <h:panelGroup />
    28         </h:panelGrid>
    29         </h:form>
    30     </ui:define>
    31 </ui:composition>
    關(guān)于Facelets視圖技術(shù),不明白的請(qǐng)查閱相關(guān)的資料,下面是最終測(cè)試結(jié)果。

    以上整合配置有經(jīng)過(guò)實(shí)際正式上線項(xiàng)目驗(yàn)證,如果你覺(jué)得有什么錯(cuò)漏,請(qǐng)多多指教。

    1.示例源碼下載,沒(méi)帶jar,需要自己去下載上面所說(shuō)的相關(guān)jar包。(94K)
    http://www.tkk7.com/Files/huliqing/Magic-JSH-Facelets-Annotation.rar

    2.示例源碼下載,完整版,包含所有相關(guān)jar,不過(guò)網(wǎng)盤(pán)可能不夠穩(wěn)定。(38M)
    http://cid-1c243f9a849aade7.skydrive.live.com/self.aspx/.Public/Magic/Magic%7C5JSF+Spring+Hibernate+Facelets+Annotation%7C6.rar


    - huliqing@huliqing.name
    - http://www.huliqing.name

    posted on 2009-03-30 18:11 huliqing 閱讀(2957) 評(píng)論(3)  編輯  收藏 所屬分類: JSF

    評(píng)論

    # re: 關(guān)于JSF1.2 + Spring2.5 + Hibernate3 + Facelets + Annotation整合配置的參考。 2009-03-30 20:51 CoderDream

    不錯(cuò),這個(gè)要支持,感謝博主分享!  回復(fù)  更多評(píng)論   

    # re: 關(guān)于JSF1.2 + Spring2.5 + Hibernate3 + Facelets + Annotation整合配置的參考。 2009-03-30 21:26 勝客

    re  回復(fù)  更多評(píng)論   

    # re: 關(guān)于JSF1.2 + Spring2.5 + Hibernate3 + Facelets + Annotation整合配置的參考。 2009-04-01 10:28 舞命小丟

    不錯(cuò)!支持一下  回復(fù)  更多評(píng)論   

    導(dǎo)航

    統(tǒng)計(jì)

    公告

    文章原創(chuàng),歡迎轉(zhuǎn)載
    ——轉(zhuǎn)載請(qǐng)注明出處及原文鏈接

    隨筆分類(60)

    隨筆檔案(33)

    最新評(píng)論

    評(píng)論排行榜

    主站蜘蛛池模板: 亚洲伦乱亚洲h视频| 色屁屁在线观看视频免费| 无码少妇精品一区二区免费动态| 丁香亚洲综合五月天婷婷| 亚洲日本一线产区和二线| 99久久99久久精品免费看蜜桃| 亚洲国产成人片在线观看| 中文毛片无遮挡高清免费| 全亚洲最新黄色特级网站| 国产精品久久久久久亚洲影视| 成年美女黄网站色大免费视频| 亚洲AV无码国产精品色| 91久久成人免费| 亚洲特级aaaaaa毛片| 最近2019免费中文字幕6| 久久精品国产亚洲AV无码娇色| 日本在线免费观看| 久久精品电影免费动漫| 亚洲精品卡2卡3卡4卡5卡区| 精品人妻系列无码人妻免费视频| 亚洲男人av香蕉爽爽爽爽| 日韩精品视频在线观看免费| 亚洲A∨精品一区二区三区| 免费亚洲视频在线观看| 免费人成网站在线高清| 免费观看又污又黄在线观看| 免费人成年轻人电影| 四虎影视永久在线精品免费| 亚洲?v女人的天堂在线观看| 日韩在线视频线视频免费网站| 亚洲国产一区视频| 国产免费内射又粗又爽密桃视频 | 久久99热精品免费观看动漫| 国产成人无码综合亚洲日韩| 精品视频在线免费观看| 亚洲第一网站男人都懂| xxxxx做受大片在线观看免费| 成人亚洲性情网站WWW在线观看| 久久国产乱子伦精品免费午夜 | 亚洲精品国产精品国自产网站| 无码人妻久久一区二区三区免费丨 |