Skip navigation

Lu's Notes

down to bottom of page

Struts: struts-config.xml

<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
		"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

  <form-beans>
	<form-bean name="somethingListForm"   (reference to an instance of form, alias name, same as JSP's use:bean)
		   type="com.web.business.someapp.form.SomethingListForm"/>    (fully qualified name)
	<form-bean name="somethingDetailForm"
		   type="com.web.business.someapp.form.SomethingDetailForm"/>
  </form-beans>

  <global-exceptions>
	<exception key="global.error.sqlException" path="/sql_exception.jsp" 
		scope="request" type="java.sql.SQLException"/>
  </global-exceptions>
  <global-forwards>
	<forward name="SystemFailure" path="/systemerror.jsp"/>
	<forward name="SessionTimeOut" path="/sessiontimeout.jsp"/>    
  </global-forwards>
  
  <action-mappings>

	<action path="/listSomething"	(any name - but must be same in JSP's <html:form action="/listSomething", 
					  also used as the  listSomething.do ) 
	        type="com.web.business.someapp.action.SomethingListAction"  (fully qualified name)
	        scope="request" 
	        name="somethingListForm"    (must be same as form-bean name="somethingListForm")
	        validate="true" 	    (or "false"  - If true, struts will invoke validate() on form-bean)
	        input="/something_list.jsp">  (.jsp page name goes here)
	  <forward name="SomethingListPage"   (define at least one forward, for Action's execute() mapping.findForward="")
		   path="/something_list.jsp"/>
	  <forward name="SomethingDetailPage" path="/something_detail.jsp"/> (use "SomePage" for jsp or "Some" for an Action)
	  <forward name="EditSomethingDetail" path="/detailSomething.do"/>  (.do will also have to be defined as action path)
	</action>
	<action path="/detailSomething" 
	        type="com.web.business.someapp.action.SomethingDetailAction" 
	        scope="request" 
	        name="somethingDetailForm" 
	        validate="true" 
	        input="/something_detail.jsp">
	  <forward name="SomethingListPage" path="/something_list.jsp"/>
	  <forward name="SomethingDetailPage" path="/something_detail.jsp"/>
	</action>
      
 </action-mappings>

  <message-resources parameter="ApplicationResources" null="false"/>
  
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
  </plug-in>
  
</struts-config>


Apache struts, struts-api, java-api, struts-html, struts-bean, struts-logic, Husted struts, KeyBoardMonkey

up to top of page   Return to Top of Page   up to top of page up to top of page