JAVA是藍(lán)色的- online
參考原文地址 http://homepage.mac.com/edahand/projects/java/example1.html1 在E盤建立一個(gè)目錄sandh, 然后把那個(gè)空的struts-blank.war解壓到這下面作為struts模板,把hibernate3.1里面的jar文件拷貝到/sandh/web-inf/lib下面,ehcache.xml拷貝到/sand/web-inf/src/java下面。2 在tomcat下配置datasource命名為jdbc/aix,然后建立一個(gè)新的context名字為sand,在sand下建一個(gè)新的資源連接jdbc/aix,作為hibernate.cfg.xml中hibernate.connection.datasouce引用值。3 在sybase中新建一個(gè)表item
4 在/sandh/web-inf/src/java下面建立以下文件log4j.properties hibernate.cfg.xmlItem.hbm.xmlHibernateUtil.javaItem.javaAddItemAction.javaItemService.java在/sandh/web-inf/src下面新建build.xml文件,然后ant compile。在/sandh/pages下新建AddItem.jsp文件5 修改/sandh/web-inf/struts-config.xml文件,內(nèi)容如下:
修改/sandh/web-inf/validation.xml文件,為addItemForm增加動(dòng)態(tài)驗(yàn)證,內(nèi)容如下:
6 在tomcat下面測(cè)試一下吧。http://127.0.0.1:8080/sand7 測(cè)試的時(shí)候發(fā)現(xiàn)2個(gè)問題:首先,如果在/sandh/web-inf/classes下面沒有ehcache.xml這個(gè)文件,會(huì)報(bào)這個(gè)錯(cuò)誤,No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath:.....這個(gè)文件是hibernate緩存配置文件,以后在學(xué)習(xí)。另外在log文件中一直發(fā)現(xiàn)這個(gè)警告:Could not bind factory to JNDI javax.naming.NamingException: Context is read only..... 網(wǎng)上查找后發(fā)現(xiàn)只要在hibernate.cfg.xml文件的<session-factory name="java:/hibernate/HibernateFactory"> 中把name=....去掉就好了,否則會(huì)自動(dòng)把name注冊(cè)進(jìn)jndi中失敗而發(fā)出警告。8 所有文件打包在這里 http://www.tkk7.com/Files/luckyrobbie/sandh.rar 里面lib下面的文件自己添進(jìn)去吧。
Powered by: BlogJava Copyright © luckyrobbie