摘要: 一直想做一個(gè) EJB3.0 結(jié)合 Struts 的例子,前天剛好從網(wǎng)上找到了一個(gè)相關(guān)的 Tutorial ,于是小試了一把,雖然只是完成了 Tutorial 上的一小點(diǎn)功能,但是感覺還是有必要寫下來(lái),免得以后還要再去看別人的Tutorial 。
開發(fā)環(huán)境:?? ??? Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...
閱讀全文
SSH(Spring + Struts + Hibernate)小試 之三
前面通過PlugIn我們實(shí)現(xiàn)了Spring Context的加載,不過僅僅加載Context并沒有什么實(shí)際
意義,我們還需要修改配置,將Struts Action交給Spring容器進(jìn)行管理。下面將通過一個(gè)Regsit
實(shí)例加以說(shuō)明。
首先準(zhǔn)備好regist.jsp和login.jsp,在regist.jsp中 的form有name,password,password2,email域。
在struts-config.xml中添加配置:
<form-bean name="registForm" type="com.lzy.forum.form.RegistForm" />
<action path="/regist" name="registForm"
type="org.springframework.web.struts.DelegatingActionProxy"
validate="true" input="/regist.jsp" scope="request">
<forward name="failure" path="/regist.jsp" />
<forward name="success" path="/login.jsp" />
</action>
RegistForm,RegistAction按照原來(lái)Struts的方法去寫,我在RegistAction中加入了一個(gè)UserDAO對(duì)象
userDAO,這個(gè)對(duì)象由Spring注入。
<bean name="/regist" class="com.lzy.forum.action.RegistAction"
singleton="false">
<property name="userDAO">
<ref local="userDAO" />
</property>
</bean>
基本上SSH的架構(gòu)已經(jīng)完成,經(jīng)確認(rèn)后可以自己測(cè)試一下了。(完)