|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.dispatcher.DefaultStaticContentLoader
public class DefaultStaticContentLoader
Default implementation to server static content
This class is used to serve common static content needed when using various parts of Struts, such as JavaScript files, CSS files, etc. It works by looking for requests to /struts/* (or /static/*), and then mapping the value after "/struts/" to common packages in Struts and, optionally, in your class path. By default, the following packages are automatically searched:
Field Summary | |
---|---|
protected String |
encoding
Store state of StrutsConstants.STRUTS_I18N_ENCODING setting. |
protected Calendar |
lastModifiedCal
Provide a formatted date for setting heading information when caching static content. |
protected List<String> |
pathPrefixes
Store set of path prefixes to use with static resources. |
protected boolean |
serveStatic
Store state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting. |
protected boolean |
serveStaticBrowserCache
Store state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting. |
Constructor Summary | |
---|---|
DefaultStaticContentLoader()
|
Method Summary | |
---|---|
protected String |
buildPath(String name,
String packagePrefix)
|
boolean |
canHandle(String resourcePath)
|
protected String |
cleanupPath(String path)
|
protected void |
copy(InputStream input,
OutputStream output)
Copy bytes from the input stream to the output stream. |
protected URL |
findResource(String path)
Look for a static resource in the classpath. |
void |
findStaticResource(String path,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Locate a static resource and copy directly to the response, setting the appropriate caching headers. |
protected String |
getAdditionalPackages()
|
protected String |
getContentType(String name)
Determine the content type for the resource name. |
protected List<String> |
parse(String packages)
Create a string array from a comma-delimited list of packages. |
protected void |
process(InputStream is,
String path,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
setEncoding(String val)
Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting. |
void |
setHostConfig(HostConfig filterConfig)
|
void |
setServeStaticBrowserCache(String val)
Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting. |
void |
setServeStaticContent(String val)
Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List<String> pathPrefixes
protected boolean serveStatic
protected boolean serveStaticBrowserCache
protected final Calendar lastModifiedCal
protected String encoding
Constructor Detail |
---|
public DefaultStaticContentLoader()
Method Detail |
---|
public void setServeStaticContent(String val)
val
- New settingpublic void setServeStaticBrowserCache(String val)
val
- New settingpublic void setEncoding(String val)
val
- New settingpublic void setHostConfig(HostConfig filterConfig)
setHostConfig
in interface StaticContentLoader
filterConfig
- The filter configurationprotected String getAdditionalPackages()
protected List<String> parse(String packages)
packages
- A comma-delimited String listing packages
public void findStaticResource(String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
StaticContentLoader
findStaticResource
in interface StaticContentLoader
path
- The resource namerequest
- The requestresponse
- The response
IOException
- If anything goes wrongprotected void process(InputStream is, String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
IOException
protected URL findResource(String path) throws IOException
path
- The resource path
IOException
- If there is a problem locating the resourceprotected String buildPath(String name, String packagePrefix) throws UnsupportedEncodingException
name
- resource namepackagePrefix
- The package prefix to use to locate the resource
UnsupportedEncodingException
protected String getContentType(String name)
name
- The resource name
protected void copy(InputStream input, OutputStream output) throws IOException
input
- The input streamoutput
- The output stream
IOException
- If anything goes wrongpublic boolean canHandle(String resourcePath)
canHandle
in interface StaticContentLoader
resourcePath
- Requested resource path
protected String cleanupPath(String path)
path
- requested path
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |