|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.dispatcher.HttpHeaderResult
public class HttpHeaderResult
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.
This result type takes the following parameters:<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>
Field Summary | |
---|---|
static String |
DEFAULT_PARAM
The default parameter |
private int |
error
|
private String |
errorMessage
|
private Map<String,String> |
headers
|
private boolean |
parse
|
private static long |
serialVersionUID
|
private int |
status
|
Constructor Summary | |
---|---|
HttpHeaderResult()
|
|
HttpHeaderResult(int status)
|
Method Summary | |
---|---|
void |
addHeader(String name,
String value)
Adds an HTTP header to the response |
void |
execute(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 |
getHeaders()
Returns a Map of all HTTP headers. |
void |
setError(int error)
Sets the http servlet error code that should be set on the reponse |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
public static final String DEFAULT_PARAM
private boolean parse
private Map<String,String> headers
private int status
private int error
private String errorMessage
Constructor Detail |
---|
public HttpHeaderResult()
public HttpHeaderResult(int status)
Method Detail |
---|
public void setError(int error)
error
- the Http error codeHttpServletResponse.sendError(int)
public void setErrorMessage(String errorMessage)
errorMessage
- error message send to the clientHttpServletResponse.sendError(int, String)
public Map getHeaders()
public void setParse(boolean parse)
parse
- true if HTTP header values should be evaluated agains the ValueStack, false
otherwise.public void setStatus(int status)
status
- the Http status codeHttpServletResponse.setStatus(int)
public void addHeader(String name, String value)
name
- value
- public void execute(ActionInvocation invocation) throws Exception
execute
in interface Result
invocation
- an encapsulation of the action execution state.
Exception
- if an error occurs when re-setting the headers.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |