Wenn die Action-Klasse unterklassifiziert ist und die Sub-Klasse keine 'execute'-Methode enthält, werden Struts automatisch nach der Super-Klasse für eine' execute'-Methode suchen? Wenn die übergeordnete Klasse der Aktionssubklasse eine Unterklasse von Action selbst ist und keine 'execute'-Methode enthält, werden die Struts weiterhin die Hierarchie nachschlagen, bis eine Superklasse gefunden wird, die die' execute'-Methode enthält ? Sucht struts immer zuerst die "execute" -Methode und führt sie aus? Unten ist ein Code, der hoffentlich meine Frage klären wird.Sub-Classing-Struts Aktionsklasse
Superklasse:
public class BaseXHRAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String page = mapping.getParameter();
String actionName = mapping.getPath();
return mapping.findForward(page);
}
}
Unterklasse:
public class OdonohueTestInitXHRAction extends BaseXHRAction {
//this class does not contain an 'execute' method
//it contains some other method(s) below
public ScreenConfigurationRes getResponse(ActionForm form, HttpServletRequest request, Context ctx) throws Exception {
//return ScreenConfigurationRes
}
}
struts-config.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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="screenConfigurationForm" type="com.saic.ct.sys.presentation.forms.screenconfiguration.ScreenConfigurationForm"/>
<form-beans>
<!-- Global Forwards -->
<global-exceptions>
<exception type="java.lang.Exception" key="Test" path="/errorAction.do"/>
</global-exceptions>
<global-forwards>
<forward name="home" path="/home.do"/>
<forward name="error" path="/errorAction.do"/>
<forward name="logoutError" path="/loginInit.do"/>
</global-forwards>
<!-- Action Mappings -->
<action-mappings>
<action
path="/OdonohueTestInitXHR"
name="screenConfigurationForm"
type="com.saic.ct.sys.presentation.actions.schedule.OdonohueTestInitXHRAction"
parameter="home"/>
</action-mappings>
<controller locale="true"/>
<plug-in className="com.oroad.stxx.plugin.StxxPlugin">
<set-property property="pipeline-config" value="/WEB-INF/stxx-pipelines.xml"/>
</plug-in>
<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>
"_Wenn Ihre Aktion die Methode execute() nicht überschreibt, verwendet sie die geerbte Methode_" Dies ist genau das, was ich bestätigen wollte. Schätzen Sie Ihre Antwort. – tommyO