org.apache.struts2.dispatcher
类 StreamResult
java.lang.Object
org.apache.struts2.dispatcher.StrutsResultSupport
org.apache.struts2.dispatcher.StreamResult
- 所有已实现的接口:
- com.opensymphony.xwork2.Result, Serializable, StrutsStatics
public class StreamResult
- extends StrutsResultSupport
A custom Result type for sending raw data (via an InputStream) directly to the
HttpServletResponse. Very useful for allowing users to download content.
This result type takes the following parameters:
- contentType - the stream mime-type as sent to the web browser
(default =
text/plain
).
- contentLength - the stream length in bytes (the browser displays a
progress bar).
- contentDisposition - the content disposition header value for
specifing the file name (default =
inline
, values are typically
attachment;filename="document.pdf".
- inputName - the name of the InputStream property from the chained
action (default =
inputStream
).
- bufferSize - the size of the buffer to copy from input to output
(default =
1024
).
- allowCaching if set to 'false' it will set the headers 'Pragma' and 'Cache-Control'
to 'no-cahce', and prevent client from caching the content. (default =
true
)
- contentCharSet if set to a string, ';charset=value' will be added to the
content-type header, where value is the string set. If set to an expression, the result
of evaluating the expression will be used. If not set, then no charset will be set on
the header
These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can
provide getContentType()
to override that parameter for the current action.
Example:
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">imageStream</param>
<param name="contentDisposition">attachment;filename="document.pdf"</param>
<param name="bufferSize">1024</param>
</result>
- 另请参见:
- 序列化表格
DEFAULT_PARAM
public static final String DEFAULT_PARAM
- 另请参见:
- 常量字段值
StreamResult
public StreamResult()
StreamResult
public StreamResult(InputStream in)
getAllowCaching
public boolean getAllowCaching()
- 返回:
- Returns the whether or not the client should be requested to allow caching of the data stream.
setAllowCaching
public void setAllowCaching(boolean allowCaching)
- Set allowCaching to false to indicate that the client should be requested not to cache the data stream.
This is set to false by default
- 参数:
allowCaching
- Enable caching.
getBufferSize
public int getBufferSize()
- 返回:
- Returns the bufferSize.
setBufferSize
public void setBufferSize(int bufferSize)
- 参数:
bufferSize
- The bufferSize to set.
getContentType
public String getContentType()
- 返回:
- Returns the contentType.
setContentType
public void setContentType(String contentType)
- 参数:
contentType
- The contentType to set.
getContentLength
public String getContentLength()
- 返回:
- Returns the contentLength.
setContentLength
public void setContentLength(String contentLength)
- 参数:
contentLength
- The contentLength to set.
getContentDisposition
public String getContentDisposition()
- 返回:
- Returns the Content-disposition header value.
setContentDisposition
public void setContentDisposition(String contentDisposition)
- 参数:
contentDisposition
- the Content-disposition header value to use.
getContentCharSet
public String getContentCharSet()
- 返回:
- Returns the charset specified by the user
setContentCharSet
public void setContentCharSet(String contentCharSet)
- 参数:
contentCharSet
- the charset to use on the header when sending the stream
getInputName
public String getInputName()
- 返回:
- Returns the inputName.
setInputName
public void setInputName(String inputName)
- 参数:
inputName
- The inputName to set.