Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Let us take a more detailed look at our struts.xml:

Code Block
xml
xml
<xwork>
	<!-- Include webwork default (from WebWork JAR). -->
	<include file="webwork-default.xml"/>

	<!-- Configuration for the default package. -->
	<package name="default" extends="webwork-default">

		<!-- Default interceptor stack. -->
		<default-interceptor-ref name="paramsPrepareParamsStack"/>
		<action name="index" class="net.vaultnet.learn.action.EmployeeAction" method="list">
			<result name="success">/jsp/employees.jsp</result>
			<!-- we don't need the full stack here -->
			<interceptor-ref name="basicStack"/>
		</action>
		<action name="crud" class="net.vaultnet.learn.action.EmployeeAction" method="input">
			<result name="success" type="redirect-action">index</result>
			<result name="input">/jsp/employeeForm.jsp</result>
			<result name="error">/jsp/error.jsp</result>
		</action>
	</package>
</xwork>

...

It gets more interesting for our crud Action: besides the success result, we also specify the input result (which dispatches to our input form) and the error result (which is returned when an exception is thrown during the Action execution - for example a database exception). You can also see we specified a different result-type for our success result, in casu the 'redirect-action'. This is nothing more than a fancy redirect which will append the chosen WW suffix, so we could have also used the redirect result-type, with index.action as its text. But this approach is slightly better since it is suffix agnostic (you can switch suffixes very easily in WW, so that is why we always advise to program suffix agnostic and let the framework handle it for you).

More information on struts.xml

WEB-INF/classes/webwork.properties

...