org.apache.struts2.dispatcher
类 HttpHeaderResult

java.lang.Object
  继承者 org.apache.struts2.dispatcher.HttpHeaderResult
所有已实现的接口:
com.opensymphony.xwork2.Result, Serializable

public class HttpHeaderResult
extends Object
implements com.opensymphony.xwork2.Result

A custom Result type for setting HTTP headers and status by optionally evaluating against the ValueStack. This result can also be used to send and error to the client. All the parameters can be evaluated against the ValueStack.

This result type takes the following parameters:

Example:


 <result name="success" type="httpheader">
   <param name="status">204</param>
   <param name="headers.a">a custom header value</param>
   <param name="headers.b">another custom header value</param>
 </result>
 

<result name="proxyRequired" type="httpheader"> <param name="error">305</param> <param name="errorMessage">this action must be accessed through a prozy</param> </result>

另请参见:
序列化表格

字段摘要
static String DEFAULT_PARAM
          This result type doesn't have a default param, null is ok to reduce noice in logs
 
构造方法摘要
HttpHeaderResult()
           
HttpHeaderResult(int status)
           
 
方法摘要
 void addHeader(String name, String value)
          Adds an HTTP header to the response
 void execute(com.opensymphony.xwork2.ActionInvocation invocation)
          Sets the optional HTTP response status code and also re-sets HTTP headers after they've been optionally evaluated against the ValueStack.
 Map<String,String> getHeaders()
          Returns a Map of all HTTP headers.
 int getStatus()
           
 void setError(String error)
          Sets the http servlet error code that should be set on the response
 void setErrorMessage(String errorMessage)
          Sets the error message that should be set on the reponse
 void setParse(boolean parse)
          Sets whether or not the HTTP header values should be evaluated against the ValueStack (by default they are).
 void setStatus(int status)
          Sets the http servlet response status code that should be set on a response.
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

DEFAULT_PARAM

public static final String DEFAULT_PARAM
This result type doesn't have a default param, null is ok to reduce noice in logs

构造方法详细信息

HttpHeaderResult

public HttpHeaderResult()

HttpHeaderResult

public HttpHeaderResult(int status)
方法详细信息

setError

public void setError(String error)
Sets the http servlet error code that should be set on the response

参数:
error - the Http error code
另请参见:
HttpServletResponse.sendError(int)

setErrorMessage

public void setErrorMessage(String errorMessage)
Sets the error message that should be set on the reponse

参数:
errorMessage - error message send to the client
另请参见:
HttpServletResponse.sendError(int, String)

getHeaders

public Map<String,String> getHeaders()
Returns a Map of all HTTP headers.

返回:
a Map of all HTTP headers.

setParse

public void setParse(boolean parse)
Sets whether or not the HTTP header values should be evaluated against the ValueStack (by default they are).

参数:
parse - true if HTTP header values should be evaluated against the ValueStack, false otherwise.

setStatus

public void setStatus(int status)
Sets the http servlet response status code that should be set on a response.

参数:
status - the Http status code
另请参见:
HttpServletResponse.setStatus(int)

getStatus

public int getStatus()

addHeader

public void addHeader(String name,
                      String value)
Adds an HTTP header to the response

参数:
name - header name
value - header value

execute

public void execute(com.opensymphony.xwork2.ActionInvocation invocation)
             throws Exception
Sets the optional HTTP response status code and also re-sets HTTP headers after they've been optionally evaluated against the ValueStack.

指定者:
接口 com.opensymphony.xwork2.Result 中的 execute
参数:
invocation - an encapsulation of the action execution state.
抛出:
Exception - if an error occurs when re-setting the headers.