Posted on 2006-08-21 23:44
兵臨城下 閱讀(1450)
評論(11) 編輯 收藏 所屬分類:
Spring
?????問題很簡單,就是用Spring 管理struts的action。
??????struts-config.xml如下:
??????<struts-config>
? <data-sources />
? <form-beans >
??? <form-bean name="logonForm" type="com.xcblcx.struts.form.LogonForm">
??? <!-- <form-property name="userName" type="java.lang.String"/>
??? <form-property name="password" type="java.lang.String"/> -->
??? </form-bean>
? </form-beans>
? <global-exceptions />
? <global-forwards />
? <action-mappings >
??? <action
????? attribute="logonForm"
????? input="/form/logon.jsp"
????? name="logonForm"
????? path="/Logon"
????? scope="request"
????? type="org.springframework.web.struts.DelegatingActionProxy">
????? <forward name="logon_sc" path="/success.jsp" />
??? </action>
? </action-mappings>
? <message-resources parameter="com.xcblcx.struts.ApplicationResources" />
?
? <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
?<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
</struts-config>
spring的配置文件:(相關片段)
<beans>
?????????........
???????<bean name="/Logon" class="com.xcblcx.struts.action.LogonAction">
??????????????<property name="CSCEDAO">
??????????????????<ref bean="programmerDAOImpl"/>
??????????????</property>
??????</bean>
?</bean>
</beans>
注入到action中的programmerDAOImpl沒有問題,我已經使用普通應用程序測試過了。
現在問題是,運行logon.jsp點擊提交后,tomcat報錯:
type
Status report
message
Servlet LogonAction is not available
description
The requested resource (Servlet LogonAction is not available) is not available.
不知道為什么, 還請大家發表意見!
附帶問一個問題,關于spring管理action的問題:一種是在Struts的Action中直接調用Spring的Bean;另一種方式是將Struts的Action作為Spring Beans,直接注入所需資源,由Spring進行管理。那種方法更好一點呢?