Struts Controller (II)
16 January 2008Please go through Struts Controller (I) before going through this post. For this post we will create hello.jsp file and map the “hello.do” request to this page.
hello.jsp
<ins datetime="2008-01-16T16:33:42+00:00"> <%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <html:html locale="true"> <head> <title><bean:message key="hello.title"/></title> <html:base/> </head> <body bgcolor="white"> <h3><bean:message key="hello.heading"/></h3> <p><bean:message key="hello.message"/></p> </body> </html:html>
Forwarding the hello.do request to hello.jsp
The “Action Mapping Definitions” is the most important part in the struts-config.xml. This section takes a form defined in the “Form Bean Definitions” section and maps it to an action class.
Following code under the
<action path="/hello" forward="/pages/hello.jsp"/>
To call this hello.jsp file we will use the following code.
<html:link page="/hello.do">First Request to the controller</html:link>
Once the use clicks on on First Request to the controller link on the index page, request (for hello.do) is sent to the Controller and the controller forwards the request to hello.jsp. The content of hello.jsp is displayed to the user.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Struts Controller (II)