Configure ForwardAction into struts-config.xml
Previous | Home | Next |
ForwardAction are mapped in the struts configuration file and this configuration is loaded into memory at startup and made available to the framework at runtime.
The ActionMapping object contains a path attribute that is matched against a portion of the URI of the incoming request.<action path="/home" type="org.apache.struts.action.ForwardAction" parameter="home.jsp"/>Thee mapping of action forward can be specified in a global section. It independent of any specific action mapping<global-forwards><forward name="Success" path="success.jsp" /> <forward name="Failure" path="index.jsp" /></global-forward>
Full Example:-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="loginForm" type="com.r4r.struts.LoginForm"/> </form-beans> <global-exceptions /> <global-forwards> <forward name="login" path="/login.do"/> </global-forwards> <action-mappings> <action path="/login" type="com.r4r.struts.LoginAction" name="loginForm"> <forward name="success" path="/success.jsp"/> <forward name="error" path="/error.jsp"/> </action> </action-mappings> <message-resources parameter="com.r4r.struts.ApplicationResources"/> </struts-config>
Previous | Home | Next |