Top Description Inners Fields Constructors Methods
org.springframework.web.bind

public abstract Class ServletRequestUtils

extends Object
Class Inheritance
Imports
jakarta.servlet.ServletRequest, org.springframework.lang.Nullable

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.

Authors
Juergen Hoeller, Keith Donald
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class
private static class
private abstract static class
private static class

Field Summary

Modifier and TypeField and Description
private static final ServletRequestUtils.BooleanParser
private static final ServletRequestUtils.DoubleParser
private static final ServletRequestUtils.FloatParser
private static final ServletRequestUtils.IntParser
private static final ServletRequestUtils.LongParser
private static final ServletRequestUtils.StringParser

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Boolean

Returns:

the Boolean value, or null if not present
getBooleanParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a Boolean parameter, or null if not present.

public static boolean
getBooleanParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
boolean
the default value to use as fallback
defaultVal
)

Get a boolean parameter, with a fallback value.

public static boolean[]
getBooleanParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of boolean parameters, return an empty array if not found.

public static Double

Returns:

the Double value, or null if not present
getDoubleParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a Double parameter, or null if not present.

public static double
getDoubleParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
double
the default value to use as fallback
defaultVal
)

Get a double parameter, with a fallback value.

public static double[]
getDoubleParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of double parameters, return an empty array if not found.

public static Float

Returns:

the Float value, or null if not present
getFloatParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a Float parameter, or null if not present.

public static float
getFloatParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
float
the default value to use as fallback
defaultVal
)

Get a float parameter, with a fallback value.

public static float[]
getFloatParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of float parameters, return an empty array if not found.

public static Integer

Returns:

the Integer value, or null if not present
getIntParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get an Integer parameter, or null if not present.

public static int
getIntParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
int
the default value to use as fallback
defaultVal
)

Get an int parameter, with a fallback value.

public static int[]
getIntParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of int parameters, return an empty array if not found.

public static Long

Returns:

the Long value, or null if not present
getLongParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a Long parameter, or null if not present.

public static long
getLongParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
long
the default value to use as fallback
defaultVal
)

Get a long parameter, with a fallback value.

public static long[]
getLongParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of long parameters, return an empty array if not found.

public static boolean
getRequiredBooleanParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a boolean parameter, throwing an exception if it isn't found or isn't a boolean.

public static boolean[]
getRequiredBooleanParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get an array of boolean parameters, throwing an exception if not found or one isn't a boolean.

public static double
getRequiredDoubleParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a double parameter, throwing an exception if it isn't found or isn't a number.

public static double[]
getRequiredDoubleParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of double parameters, throwing an exception if not found or one is not a number.

public static float
getRequiredFloatParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a float parameter, throwing an exception if it isn't found or isn't a number.

public static float[]
getRequiredFloatParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of float parameters, throwing an exception if not found or one is not a number.

public static int
getRequiredIntParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get an int parameter, throwing an exception if it isn't found or isn't a number.

public static int[]
getRequiredIntParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of int parameters, throwing an exception if not found or one is not a number.

public static long
getRequiredLongParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a long parameter, throwing an exception if it isn't found or isn't a number.

public static long[]
getRequiredLongParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of long parameters, throwing an exception if not found or one is not a number.

public static String
getRequiredStringParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a String parameter, throwing an exception if it isn't found.

public static String[]
getRequiredStringParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get an array of String parameters, throwing an exception if not found.

public static String

Returns:

the String value, or null if not present
getStringParameter
(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
)

Get a String parameter, or null if not present.

public static String
getStringParameter(ServletRequest
current HTTP request
request
,
String
the name of the parameter
name
,
String
the default value to use as fallback
defaultVal
)

Get a String parameter, with a fallback value.

public static String[]
getStringParameters(ServletRequest
current HTTP request
request
,
String
the name of the parameter with multiple possible values
name
)

Get an array of String parameters, return an empty array if not found.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait