To get a handle on Struts and Spring for as400 web dev, im working through Struts Live, and trying to get each example working in the Struts/Spring combo as I go along.
Im running this stuff on tomcat 4.1.29 and using Eclipse M9 as my IDE (Luv it!)
Configured web.xml for the Struts ActionServlet
<servlet>
<servlet-name>action<//servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
<//servlet-class>
<init-param>
<param-name>config<//param-name>
<param-value>//WEB-INF//struts-config.xml<//param-value>
<//init-param>
<load-on-startup>2<//load-on-startup>
<//servlet>
The first example action is strutstutorial.UserRegistrationAction, and all that does is to request a forward to the view "success".
return mapping.findForward("success");
The success jsp is as simple as
<html>
<head>
<title>
User Registration Was Successful!
</title>
</head>
<body>
<h1>User Registration Was Successful!</h1>
</body>
</html>
Add an action mapping to Struts config to url to the action handler class by adding the following to \WEB-INF\struts-config.xml
<action path="//userRegistration"
type="strutsTutorial.UserRegistrationAction">
<forward name="success" path="//regSuccess.jsp"//>
<//action>
i deployed this stuff to tomcat, and it worked. Now to change this to work with Spring.
Added the relevant jars to my eclipse project from the Spring distribution.
Added the struts-spring plugin jar
Added a reference to the plugin in struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="//WEB-INF//spring-beans.xml"//>
<//plug-in>
Modified the type on the action mapping in struts-config.xml
<action path="//userRegistration"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="//regSuccess.jsp"//>
<//action>
Reference to the action class in spring-beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-////SPRING////DTD BEAN////EN"
"http:////www.springframework.org//dtd//spring-beans.dtd">
<beans>
<bean name="//userRegistration"
class="strutsTutorial.UserRegistrationAction">
<//bean>
<//beans>
i thought that this should have been enough, but when I ran the app on Tomcat I got an error because applicationContext.xml could not be located. So i create a blank one in WEB-INF.
Pointed at the URL, and this worked, yeah my first meaningful foray into Struts and Spring. as400 web dev here we come
Tuesday, June 08, 2004
Subscribe to:
Post Comments (Atom)
Popular Posts
- Linux Forum: Apache, Webmin and Mandrake - Linux Operating System Help
- Yahoo! Mail: Revenge of the Oddpost
- Free AS400 & iSeries Software Tools & Utilities Downloads
- The Laughing Boardroom video...a real world example!
- IBM eServer iSeries - The Laughing Boardroom
- Basic Requirements of a JavaServer Faces Application
- UDATE and *DATE in AS400 RPG
- AS400 APIs
- Encrypt Data on as400 (QC3ENCDT, Qc3EncryptData)
- Creating an as400 Query
No comments:
Post a Comment