|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.web.bind.RequestUtils
Parameter extraction methods, for an approach distinct from data binding, in which parameters of specific types are required.
This approach is very useful for simple submissions, where binding request parameters to a command object would be overkill.
Constructor Summary | |
RequestUtils()
|
Method Summary | |
static boolean |
getBooleanParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
boolean defaultVal)
Get a boolean parameter, with a fallback value. |
static double |
getDoubleParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
double defaultVal)
Get a double parameter, with a fallback value. |
static float |
getFloatParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
float defaultVal)
Get a double parameter, with a fallback value. |
static int |
getIntParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
int defaultVal)
Get an int parameter, with a fallback value. |
static long |
getLongParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
long defaultVal)
Get an int parameter, with a fallback value. |
static boolean |
getRequiredBooleanParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get a boolean parameter, throwing an exception if it isn't found or isn't a boolean. |
static double |
getRequiredDoubleParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get a double parameter, throwing an exception if it isn't found or isn't a number. |
static float |
getRequiredFloatParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get a double parameter, throwing an exception if it isn't found or isn't a number. |
static int |
getRequiredIntParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get an int parameter, throwing an exception if it isn't found or isn't a number. |
static long |
getRequiredLongParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get a long parameter, throwing an exception if it isn't found or isn't a number. |
static java.lang.String |
getRequiredStringParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Get a string parameter, throwing an exception if it isn't found or is empty. |
static java.lang.String |
getStringParameter(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.String defaultVal)
Get a string parameter, with a fallback value. |
static void |
rejectRequestMethod(javax.servlet.http.HttpServletRequest request,
java.lang.String method)
Throw a ServletException if the given HTTP request method should be rejected. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RequestUtils()
Method Detail |
public static void rejectRequestMethod(javax.servlet.http.HttpServletRequest request, java.lang.String method) throws javax.servlet.ServletException
request
- request to checkmethod
- method (such as "GET") which should be rejected
javax.servlet.ServletException
- if the given HTTP request is rejectedpublic static int getIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static int getRequiredIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
public static long getLongParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, long defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static long getRequiredLongParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
public static float getFloatParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, float defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static float getRequiredFloatParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
public static double getDoubleParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, double defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static double getRequiredDoubleParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
public static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, boolean defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static boolean getRequiredBooleanParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
public static java.lang.String getStringParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static java.lang.String getRequiredStringParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException:
- subclass of ServletException,
so it doesn't need to be caught
ServletRequestBindingException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |