public class AssetServlet
extends javax.servlet.http.HttpServlet
| Constructor and Description |
|---|
AssetServlet(String resourcePath,
String uriPath,
String indexFile,
Charset defaultCharset)
Creates a new
AssetServlet that serves static assets loaded from resourceURL
(typically a file: or jar: URL). |
AssetServlet(String resourcePath,
String uriPath,
String indexFile,
String defaultMediaType,
Charset defaultCharset)
Creates a new
AssetServlet that serves static assets loaded from resourceURL
(typically a file: or jar: URL). |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) |
Charset |
getDefaultCharset() |
String |
getDefaultMediaType() |
String |
getIndexFile() |
URL |
getResourceURL() |
protected URL |
getResourceUrl(String absoluteRequestedResourcePath) |
String |
getUriPath() |
protected byte[] |
readResource(URL requestedResourceURL) |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, servicepublic AssetServlet(String resourcePath, String uriPath, @Nullable String indexFile, @Nullable Charset defaultCharset)
AssetServlet that serves static assets loaded from resourceURL
(typically a file: or jar: URL). The assets are served at URIs rooted at uriPath. For
example, given a resourceURL of "file:/data/assets" and a uriPath of
"/js", an AssetServlet would serve the contents of /data/assets/example.js in response to a request for /js/example.js. If a directory
is requested and indexFile is defined, then AssetServlet will attempt to
serve a file with that name in that directory. If a directory is requested and indexFile is null, it will serve a 404.resourcePath - the base URL from which assets are loadeduriPath - the URI path fragment in which all requests are rootedindexFile - the filename to use when directories are requested, or null to serve no
indexesdefaultCharset - the default character setpublic AssetServlet(String resourcePath, String uriPath, @Nullable String indexFile, @Nullable String defaultMediaType, @Nullable Charset defaultCharset)
AssetServlet that serves static assets loaded from resourceURL
(typically a file: or jar: URL). The assets are served at URIs rooted at uriPath. For
example, given a resourceURL of "file:/data/assets" and a uriPath of
"/js", an AssetServlet would serve the contents of /data/assets/example.js in response to a request for /js/example.js. If a directory
is requested and indexFile is defined, then AssetServlet will attempt to
serve a file with that name in that directory. If a directory is requested and indexFile is null, it will serve a 404.resourcePath - the base URL from which assets are loadeduriPath - the URI path fragment in which all requests are rootedindexFile - the filename to use when directories are requested, or null to serve no
indexesdefaultMediaType - the default media typedefaultCharset - the default character setpublic URL getResourceURL()
public String getUriPath()
public String getDefaultMediaType()
protected void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
IOException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOExceptionprotected byte[] readResource(URL requestedResourceURL) throws IOException
IOExceptionCopyright © 2020. All rights reserved.