You are on page 1of 4

Digital Book® Heart of the Struts Framework

A division of ActiveNET®

struts-config.xml
<struts-config>

<data-sources> Optional
<data-source> This element is used only when connection pool objects are required
</data-source>
</data-sources>

<form-beans>
<form-bean> Mandatory
<form-property/> For each form used in struts framework requires one copy for-bean element
</form-bean>
</form-beans>

<global-exceptions>
Optional
<exception> Exceptions commonly raised through out our application are handled via
</exception> this element
</global-exceptions>

<global-forwards>
<forward> Optional
ActionForwards returned from more than one Action class are configured
</forward> here
</global-forwards>

<action-mappings>
<action> Mandatory
<exception/> For each Form one Action class is required to handle business logic,
such Action class are configured here
<forward/>
</action>
</action-mappings>
Optional This element is used if want to configure our own RequestProcessor
<controller/> class

<message-resources/> NA This element is used to configure messages used often in struts framework

<plug-in/> Optional This element is used only when validation and Tiles frameworks are
used
</struts-config>

1
Digital Book® Heart of the Struts Framework
A division of ActiveNET®

<struts-config>

<data-sources>
<data-source>
</data-source>
</data-sources>

<form-beans>
<form-bean>
<form-property/>
!" </form-bean>
!" </form-beans>
!
"
!" <global-exceptions>
# !
" <exception>
</exception>
</global-exceptions>

<global-forwards>
<forward>
</forward>
</global-forwards>

<action-mappings>
<action>
<exception/>
<forward/>
</action>
</action-mappings>

<controller/>

<message-resources/>

<plug-in/>

</struts-config>

2
Digital Book® Heart of the Struts Framework
A division of ActiveNET®

! " # $%&
public ActionServlet() {} $% $ $
init(ServletConfig config) $ $
{mc=initModuleConfig();} $ '
service(req, resp){} $%
service(hreq, hresp){}
($$
) " &
$ * " &
doGet(hreq, hresp){} doPost(hreq, hresp){}

process(hreq, hresp)
{
}

public class RequestProcessor extends Object {


init(ActionServlet, ModuleConfig){}
process(hreq, resp) {}

processActionForm(hreq, hresp){}
processActionCreate(hreq, hresp){}
processForward(hreq, hresp){}
processException(hreq, hresp){}
}

ActionForm Action
setXXX(){} execute(){
setXXX(){} }
JSP
validate(){} SUCCESS Success.jsp
FAILED Failed.jsp
Home index.jsp

JDBC EJB
DAO

DB

3
Digital Book® Heart of the Struts Framework
A division of ActiveNET®

You might also like