|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.bind.RequestUtils
public abstract class 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.
ServletRequestUtils
Constructor Summary | |
---|---|
RequestUtils()
Deprecated. |
Method Summary | |
---|---|
static Boolean |
getBooleanParameter(HttpServletRequest request,
String name)
Deprecated. Get a Boolean parameter, or null if not present. |
static boolean |
getBooleanParameter(HttpServletRequest request,
String name,
boolean defaultVal)
Deprecated. Get a boolean parameter, with a fallback value. |
static boolean[] |
getBooleanParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of boolean parameters, return an empty array if not found. |
static Double |
getDoubleParameter(HttpServletRequest request,
String name)
Deprecated. Get a Double parameter, or null if not present. |
static double |
getDoubleParameter(HttpServletRequest request,
String name,
double defaultVal)
Deprecated. Get a double parameter, with a fallback value. |
static double[] |
getDoubleParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of double parameters, return an empty array if not found. |
static Float |
getFloatParameter(HttpServletRequest request,
String name)
Deprecated. Get a Float parameter, or null if not present. |
static float |
getFloatParameter(HttpServletRequest request,
String name,
float defaultVal)
Deprecated. Get a float parameter, with a fallback value. |
static float[] |
getFloatParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of float parameters, return an empty array if not found. |
static Integer |
getIntParameter(HttpServletRequest request,
String name)
Deprecated. Get an Integer parameter, or null if not present. |
static int |
getIntParameter(HttpServletRequest request,
String name,
int defaultVal)
Deprecated. Get an int parameter, with a fallback value. |
static int[] |
getIntParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of int parameters, return an empty array if not found. |
static Long |
getLongParameter(HttpServletRequest request,
String name)
Deprecated. Get a Long parameter, or null if not present. |
static long |
getLongParameter(HttpServletRequest request,
String name,
long defaultVal)
Deprecated. Get a long parameter, with a fallback value. |
static long[] |
getLongParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of long parameters, return an empty array if not found. |
static boolean |
getRequiredBooleanParameter(HttpServletRequest request,
String name)
Deprecated. Get a boolean parameter, throwing an exception if it isn't found or isn't a boolean. |
static boolean[] |
getRequiredBooleanParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of boolean parameters, throwing an exception if not found or one isn't a boolean. |
static double |
getRequiredDoubleParameter(HttpServletRequest request,
String name)
Deprecated. Get a double parameter, throwing an exception if it isn't found or isn't a number. |
static double[] |
getRequiredDoubleParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of double parameters, throwing an exception if not found or one is not a number. |
static float |
getRequiredFloatParameter(HttpServletRequest request,
String name)
Deprecated. Get a float parameter, throwing an exception if it isn't found or isn't a number. |
static float[] |
getRequiredFloatParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of float parameters, throwing an exception if not found or one is not a number. |
static int |
getRequiredIntParameter(HttpServletRequest request,
String name)
Deprecated. Get an int parameter, throwing an exception if it isn't found or isn't a number. |
static int[] |
getRequiredIntParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of int parameters, throwing an exception if not found or one is not a number.. |
static long |
getRequiredLongParameter(HttpServletRequest request,
String name)
Deprecated. Get a long parameter, throwing an exception if it isn't found or isn't a number. |
static long[] |
getRequiredLongParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of long parameters, throwing an exception if not found or one is not a number. |
static String |
getRequiredStringParameter(HttpServletRequest request,
String name)
Deprecated. Get a String parameter, throwing an exception if it isn't found or is empty. |
static String[] |
getRequiredStringParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of String parameters, throwing an exception if not found or one is empty. |
static String |
getStringParameter(HttpServletRequest request,
String name)
Deprecated. Get a String parameter, or null if not present. |
static String |
getStringParameter(HttpServletRequest request,
String name,
String defaultVal)
Deprecated. Get a String parameter, with a fallback value. |
static String[] |
getStringParameters(HttpServletRequest request,
String name)
Deprecated. Get an array of String parameters, return an empty array if not found. |
static void |
rejectRequestMethod(HttpServletRequest request,
String method)
Deprecated. 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(HttpServletRequest request, String method) throws ServletException
request
- request to checkmethod
- method (such as "GET") which should be rejected
ServletException
- if the given HTTP request is rejectedpublic static Integer getIntParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static int getIntParameter(HttpServletRequest request, String name, int defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static int[] getIntParameters(HttpServletRequest request, String name)
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static int getRequiredIntParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static int[] getRequiredIntParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter with multiple possible values
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static Long getLongParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static long getLongParameter(HttpServletRequest request, String name, long defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static long[] getLongParameters(HttpServletRequest request, String name)
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static long getRequiredLongParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static long[] getRequiredLongParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter with multiple possible values
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static Float getFloatParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static float getFloatParameter(HttpServletRequest request, String name, float defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static float[] getFloatParameters(HttpServletRequest request, String name)
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static float getRequiredFloatParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static float[] getRequiredFloatParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter with multiple possible values
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static Double getDoubleParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a number.
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static double getDoubleParameter(HttpServletRequest request, String name, double defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static double[] getDoubleParameters(HttpServletRequest request, String name)
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static double getRequiredDoubleParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static double[] getRequiredDoubleParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter with multiple possible values
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static Boolean getBooleanParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value isn't a boolean.
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static boolean getBooleanParameter(HttpServletRequest request, String name, boolean defaultVal)
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static boolean[] getBooleanParameters(HttpServletRequest request, String name)
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static boolean getRequiredBooleanParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static boolean[] getRequiredBooleanParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static String getStringParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
null
if not present.
Throws an exception if it the parameter value is empty.
request
- current HTTP requestname
- the name of the parameter
null
if not present
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static String getStringParameter(HttpServletRequest request, String name, String defaultVal)
request
- current HTTP requestname
- the name of the parameterdefaultVal
- the default value to use as fallbackpublic static String[] getStringParameters(HttpServletRequest request, String name)
request
- current HTTP requestname
- the name of the parameter with multiple possible valuespublic static String getRequiredStringParameter(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caughtpublic static String[] getRequiredStringParameters(HttpServletRequest request, String name) throws ServletRequestBindingException
request
- current HTTP requestname
- the name of the parameter
ServletRequestBindingException
- a subclass of ServletException,
so it doesn't need to be caught
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |