|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.springframework.web.util.WebUtils
Miscellaneous utilities for web applications. Used by various framework classes.
| Field Summary | |
static java.lang.String |
DEFAULT_CHARACTER_ENCODING
Default character encoding to use when request.getCharacterEncoding returns null, according to the Servlet spec. |
static java.lang.String |
DEFAULT_WEB_APP_ROOT_KEY
Default web app root key: "webapp.root" |
static java.lang.String[] |
SUBMIT_IMAGE_SUFFIXES
Name suffixes in case of image buttons |
static java.lang.String |
TEMP_DIR_CONTEXT_ATTRIBUTE
Standard Servlet spec context attribute that specifies a temporary directory for the current web application, of type java.io.File |
static java.lang.String |
WEB_APP_ROOT_KEY_PARAM
Web app root key parameter at the servlet context level (i.e. |
| Constructor Summary | |
WebUtils()
|
|
| Method Summary | |
static javax.servlet.http.Cookie |
getCookie(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Retrieve the first cookie with the given name. |
static java.lang.Object |
getOrCreateSessionAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Class clazz)
Get the specified session attribute, creating and setting a new attribute if no existing found. |
static java.util.Map |
getParametersStartingWith(javax.servlet.ServletRequest request,
java.lang.String base)
Convenience method to return a map from un-prefixed property names to values. |
static java.lang.Object |
getRequiredSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Check the given request for a session attribute of the given name. |
static java.lang.Object |
getSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Check the given request for a session attribute of the given name. |
static java.io.File |
getTempDir(javax.servlet.ServletContext servletContext)
Return the temporary directory for the current web application, as provided by the servlet container. |
static boolean |
hasSubmitParameter(javax.servlet.ServletRequest request,
java.lang.String name)
Checks if a specific input type="submit" parameter was sent in the request, either via a button (directly with name) or via an image (name + ".x" or name + ".y"). |
static void |
setSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.Object value)
Set the session attribute with the given name to the given value. |
static void |
setWebAppRootSystemProperty(javax.servlet.ServletContext servletContext)
Set a system property to the web application root directory. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String DEFAULT_CHARACTER_ENCODING
ServletRequest.getCharacterEncoding(),
Constant Field Valuespublic static final java.lang.String TEMP_DIR_CONTEXT_ATTRIBUTE
public static final java.lang.String WEB_APP_ROOT_KEY_PARAM
public static final java.lang.String DEFAULT_WEB_APP_ROOT_KEY
public static final java.lang.String[] SUBMIT_IMAGE_SUFFIXES
| Constructor Detail |
public WebUtils()
| Method Detail |
public static void setWebAppRootSystemProperty(javax.servlet.ServletContext servletContext)
throws java.lang.IllegalStateException
Can be used for toolkits that support substition with System.getProperty values, like Log4J's "${key}" syntax within log file locations.
servletContext - the servlet context of the web application
java.lang.IllegalStateException - if the system property is already set,
or if the WAR file is not expandedWEB_APP_ROOT_KEY_PARAM,
DEFAULT_WEB_APP_ROOT_KEY,
WebAppRootListener,
Log4jWebConfigurerpublic static java.io.File getTempDir(javax.servlet.ServletContext servletContext)
servletContext - the servlet context of the web application
public static java.lang.Object getSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
request - current HTTP requestname - the name of the session attribute
public static java.lang.Object getRequiredSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
throws java.lang.IllegalStateException
request - current HTTP requestname - the name of the session attribute
java.lang.IllegalStateException - if the session attribute could not be found
public static void setSessionAttribute(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.Object value)
request - current HTTP requestname - the name of the session attribute
public static java.lang.Object getOrCreateSessionAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Class clazz)
throws java.lang.IllegalArgumentException
session - current HTTP sessionname - the name of the session attributeclazz - the class to instantiate for a new attribute
java.lang.IllegalArgumentException - if the session attribute could not be instantiated
public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
name - cookie name
public static java.util.Map getParametersStartingWith(javax.servlet.ServletRequest request,
java.lang.String base)
request - HTTP request in which to look for parametersbase - beginning of parameter name
(if this is null or the empty string, all parameters will match)
public static boolean hasSubmitParameter(javax.servlet.ServletRequest request,
java.lang.String name)
request - current HTTP requestname - name of the parameter
SUBMIT_IMAGE_SUFFIXES
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||