📄 action.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Mar 09 15:31:22 GMT 2006 -->
<TITLE>
Apache Struts API Documentation: Class Action
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Action.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../../org/apache/struts/action/ActionError.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Action.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.struts.action</FONT>
<BR>
Class Action</H2>
<PRE>
java.lang.Object
|
+--<B>org.apache.struts.action.Action</B>
</PRE>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../org/apache/struts/tiles/actions/DefinitionDispatcherAction.html">DefinitionDispatcherAction</A>, <A HREF="../../../../org/apache/struts/actions/DispatchAction.html">DispatchAction</A>, <A HREF="../../../../org/apache/struts/actions/DownloadAction.html">DownloadAction</A>, <A HREF="../../../../org/apache/struts/actions/ForwardAction.html">ForwardAction</A>, <A HREF="../../../../org/apache/struts/actions/IncludeAction.html">IncludeAction</A>, <A HREF="../../../../org/apache/struts/actions/LocaleAction.html">LocaleAction</A>, <A HREF="../../../../org/apache/struts/tiles/actions/ReloadDefinitionsAction.html">ReloadDefinitionsAction</A>, <A HREF="../../../../org/apache/struts/actions/SwitchAction.html">SwitchAction</A>, <A HREF="../../../../org/apache/struts/tiles/actions/TilesAction.html">TilesAction</A>, <A HREF="../../../../org/apache/struts/tiles/actions/ViewDefinitionsAction.html">ViewDefinitionsAction</A></DD>
</DL>
<HR>
<DL>
<DT>public class <B>Action</B><DT>extends java.lang.Object</DL>
<P>
<p>An <strong>Action</strong> is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. The controller (RequestProcessor) will select an appropriate Action for each request, create an instance (if necessary), and call the <code>execute</code> method.</p> <p>Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests. This means you should design with the following items in mind: </p> <ul> <li>Instance and static variables MUST NOT be used to store information related to the state of a particular request. They MAY be used to share global resources across requests for the same action.</li> <li>Access to other resources (JavaBeans, session variables, etc.) MUST be synchronized if those resources require protection. (Generally, however, resource classes should be designed to provide their own protection where necessary.</li> </ul> <p>When an <code>Action</code> instance is first created, the controller will call <code>setServlet</code> with a non-null argument to identify the servlet instance to which this Action is attached. When the servlet is to be shut down (or restarted), the <code>setServlet</code> method will be called with a <code>null</code> argument, which can be used to clean up any allocated resources in use by this Action.</p>
<P>
<DL>
<DT><B>Version: </B><DD>$Rev: 164530 $ $Date: 2005-04-25 04:11:07 +0100 (Mon, 25 Apr 2005) $</DD>
</DL>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected static java.util.Locale</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#defaultLocale">defaultLocale</A></B></CODE>
<BR>
<B>Deprecated.</B> <I>Use Locale.getDefault directly. This will be removed after Struts 1.2.</I></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected <A HREF="../../../../org/apache/struts/action/ActionServlet.html">ActionServlet</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#servlet">servlet</A></B></CODE>
<BR>
The servlet to which we are attached.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static <A HREF="../../../../org/apache/struts/util/TokenProcessor.html">TokenProcessor</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#token">token</A></B></CODE>
<BR>
An instance of <code>TokenProcessor</code> to use for token functionality.</TD>
</TR>
</TABLE>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#Action()">Action</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#addErrors(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)">addErrors</A></B>(javax.servlet.http.HttpServletRequest request, <A HREF="../../../../org/apache/struts/action/ActionMessages.html">ActionMessages</A> errors)</CODE>
<BR>
Adds the specified errors keys into the appropriate request attribute for use by the <html:errors> tag, if any messages are required.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#addMessages(javax.servlet.http.HttpServletRequest, org.apache.struts.action.ActionMessages)">addMessages</A></B>(javax.servlet.http.HttpServletRequest request, <A HREF="../../../../org/apache/struts/action/ActionMessages.html">ActionMessages</A> messages)</CODE>
<BR>
Adds the specified messages keys into the appropriate request attribute for use by the <html:messages> tag (if messages="true" is set), if any messages are required.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../org/apache/struts/action/ActionForward.html">ActionForward</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">execute</A></B>(<A HREF="../../../../org/apache/struts/action/ActionMapping.html">ActionMapping</A> mapping, <A HREF="../../../../org/apache/struts/action/ActionForm.html">ActionForm</A> form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)</CODE>
<BR>
Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../org/apache/struts/action/ActionForward.html">ActionForward</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.ServletRequest, javax.servlet.ServletResponse)">execute</A></B>(<A HREF="../../../../org/apache/struts/action/ActionMapping.html">ActionMapping</A> mapping, <A HREF="../../../../org/apache/struts/action/ActionForm.html">ActionForm</A> form, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)</CODE>
<BR>
Process the specified non-HTTP request, and create the corresponding non-HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#generateToken(javax.servlet.http.HttpServletRequest)">generateToken</A></B>(javax.servlet.http.HttpServletRequest request)</CODE>
<BR>
Generate a new transaction token, to be used for enforcing a single request for a particular transaction.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected javax.sql.DataSource</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/struts/action/Action.html#getDataSource(javax.servlet.http.HttpServletRequest)">getDataSource</A></B>(javax.servlet.http.HttpServletRequest request)</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -