摘要: 一直想做一個 EJB3.0 結合 Struts 的例子,前天剛好從網上找到了一個相關的 Tutorial ,于是小試了一把,雖然只是完成了 Tutorial 上的一小點功能,但是感覺還是有必要寫下來,免得以后還要再去看別人的Tutorial 。
開發環境:?? ??? Eclipse3.2 + WTP1.5 , JBoss 4.0.3SP1 , jboss-EJB-3.0_RC...
閱讀全文
SSH(Spring + Struts + Hibernate)小試 之三
前面通過PlugIn我們實現了Spring Context的加載,不過僅僅加載Context并沒有什么實際
意義,我們還需要修改配置,將Struts Action交給Spring容器進行管理。下面將通過一個Regsit
實例加以說明。
首先準備好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按照原來Struts的方法去寫,我在RegistAction中加入了一個UserDAO對象
userDAO,這個對象由Spring注入。
<bean name="/regist" class="com.lzy.forum.action.RegistAction"
singleton="false">
<property name="userDAO">
<ref local="userDAO" />
</property>
</bean>
基本上SSH的架構已經完成,經確認后可以自己測試一下了。(完)