Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.bind
Class ServletRequestUtils

    java.lang.Object
      org.springframework.web.bind.ServletRequestUtils

    public abstract class ServletRequestUtils

extends java.lang.Object

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.

Since:
  2.0
Author:
  Juergen Hoeller, Keith Donald

Constructor Summary
`ServletRequestUtils()`

Method Summary
`static java.lang.Boolean` | `getBooleanParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a Boolean parameter, or `null` if not present.
`static boolean` | `getBooleanParameter(javax.servlet.ServletRequest request, java.lang.String name, boolean defaultVal)` Get a boolean parameter, with a fallback value.
`static boolean[]` | `getBooleanParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of boolean parameters, return an empty array if not found.
`static java.lang.Double` | `getDoubleParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a Double parameter, or `null` if not present.
`static double` | `getDoubleParameter(javax.servlet.ServletRequest request, java.lang.String name, double defaultVal)` Get a double parameter, with a fallback value.
`static double[]` | `getDoubleParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of double parameters, return an empty array if not found.
`static java.lang.Float` | `getFloatParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a Float parameter, or `null` if not present.
`static float` | `getFloatParameter(javax.servlet.ServletRequest request, java.lang.String name, float defaultVal)` Get a float parameter, with a fallback value.
`static float[]` | `getFloatParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of float parameters, return an empty array if not found.
`static java.lang.Integer` | `getIntParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get an Integer parameter, or `null` if not present.
`static int` | `getIntParameter(javax.servlet.ServletRequest request, java.lang.String name, int defaultVal)` Get an int parameter, with a fallback value.
`static int[]` | `getIntParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of int parameters, return an empty array if not found.
`static java.lang.Long` | `getLongParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a Long parameter, or `null` if not present.
`static long` | `getLongParameter(javax.servlet.ServletRequest request, java.lang.String name, long defaultVal)` Get a long parameter, with a fallback value.
`static long[]` | `getLongParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of long parameters, return an empty array if not found.
`static boolean` | `getRequiredBooleanParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a boolean parameter, throwing an exception if it isn't found or isn't a boolean.
`static boolean[]` | `getRequiredBooleanParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of boolean parameters, throwing an exception if not found or one isn't a boolean.
`static double` | `getRequiredDoubleParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a double parameter, throwing an exception if it isn't found or isn't a number.
`static double[]` | `getRequiredDoubleParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of double parameters, throwing an exception if not found or one is not a number.
`static float` | `getRequiredFloatParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a float parameter, throwing an exception if it isn't found or isn't a number.
`static float[]` | `getRequiredFloatParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of float parameters, throwing an exception if not found or one is not a number.
`static int` | `getRequiredIntParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get an int parameter, throwing an exception if it isn't found or isn't a number.
`static int[]` | `getRequiredIntParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of int parameters, throwing an exception if not found or one is not a number..
`static long` | `getRequiredLongParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a long parameter, throwing an exception if it isn't found or isn't a number.
`static long[]` | `getRequiredLongParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of long parameters, throwing an exception if not found or one is not a number.
`static java.lang.String` | `getRequiredStringParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a String parameter, throwing an exception if it isn't found.
`static java.lang.String[]` | `getRequiredStringParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of String parameters, throwing an exception if not found.
`static java.lang.String` | `getStringParameter(javax.servlet.ServletRequest request, java.lang.String name)` Get a String parameter, or `null` if not present.
`static java.lang.String` | `getStringParameter(javax.servlet.ServletRequest request, java.lang.String name, java.lang.String defaultVal)` Get a String parameter, with a fallback value.
`static java.lang.String[]` | `getStringParameters(javax.servlet.ServletRequest request, java.lang.String name)` Get an array of String parameters, return an empty array if not found.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ServletRequestUtils

    public ServletRequestUtils()

Method Detail

### getIntParameter

    public static java.lang.Integer getIntParameter(javax.servlet.ServletRequest request,
                                                    java.lang.String name)
                                             throws ServletRequestBindingException

  Get an Integer parameter, or `null` if not present. Throws an exception if it the parameter value isn't a number.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the Integer value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getIntParameter

    public static int getIntParameter(javax.servlet.ServletRequest request,
                                      java.lang.String name,
                                      int defaultVal)

  Get an int parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getIntParameters

    public static int[] getIntParameters(javax.servlet.ServletRequest request,
                                         java.lang.String name)

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredIntParameter

    public static int getRequiredIntParameter(javax.servlet.ServletRequest request,
                                              java.lang.String name)
                                       throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredIntParameters

    public static int[] getRequiredIntParameters(javax.servlet.ServletRequest request,
                                                 java.lang.String name)
                                          throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getLongParameter

    public static java.lang.Long getLongParameter(javax.servlet.ServletRequest request,
                                                  java.lang.String name)
                                           throws ServletRequestBindingException

  Get a Long parameter, or `null` if not present. Throws an exception if it the parameter value isn't a number.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the Long value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getLongParameter

    public static long getLongParameter(javax.servlet.ServletRequest request,
                                        java.lang.String name,
                                        long defaultVal)

  Get a long parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getLongParameters

    public static long[] getLongParameters(javax.servlet.ServletRequest request,
                                           java.lang.String name)

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredLongParameter

    public static long getRequiredLongParameter(javax.servlet.ServletRequest request,
                                                java.lang.String name)
                                         throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredLongParameters

    public static long[] getRequiredLongParameters(javax.servlet.ServletRequest request,
                                                   java.lang.String name)
                                            throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getFloatParameter

    public static java.lang.Float getFloatParameter(javax.servlet.ServletRequest request,
                                                    java.lang.String name)
                                             throws ServletRequestBindingException

  Get a Float parameter, or `null` if not present. Throws an exception if it the parameter value isn't a number.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the Float value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getFloatParameter

    public static float getFloatParameter(javax.servlet.ServletRequest request,
                                          java.lang.String name,
                                          float defaultVal)

  Get a float parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getFloatParameters

    public static float[] getFloatParameters(javax.servlet.ServletRequest request,
                                             java.lang.String name)

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredFloatParameter

    public static float getRequiredFloatParameter(javax.servlet.ServletRequest request,
                                                  java.lang.String name)
                                           throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredFloatParameters

    public static float[] getRequiredFloatParameters(javax.servlet.ServletRequest request,
                                                     java.lang.String name)
                                              throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getDoubleParameter

    public static java.lang.Double getDoubleParameter(javax.servlet.ServletRequest request,
                                                      java.lang.String name)
                                               throws ServletRequestBindingException

  Get a Double parameter, or `null` if not present. Throws an exception if it the parameter value isn't a number.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the Double value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getDoubleParameter

    public static double getDoubleParameter(javax.servlet.ServletRequest request,
                                            java.lang.String name,
                                            double defaultVal)

  Get a double parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getDoubleParameters

    public static double[] getDoubleParameters(javax.servlet.ServletRequest request,
                                               java.lang.String name)

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredDoubleParameter

    public static double getRequiredDoubleParameter(javax.servlet.ServletRequest request,
                                                    java.lang.String name)
                                             throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredDoubleParameters

    public static double[] getRequiredDoubleParameters(javax.servlet.ServletRequest request,
                                                       java.lang.String name)
                                                throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getBooleanParameter

    public static java.lang.Boolean getBooleanParameter(javax.servlet.ServletRequest request,
                                                        java.lang.String name)
                                                 throws ServletRequestBindingException

  Get a Boolean parameter, or `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).

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the Boolean value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getBooleanParameter

    public static boolean getBooleanParameter(javax.servlet.ServletRequest request,
                                              java.lang.String name,
                                              boolean defaultVal)

  Get a boolean parameter, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

  Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getBooleanParameters

    public static boolean[] getBooleanParameters(javax.servlet.ServletRequest request,
                                                 java.lang.String name)

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

  Accepts "true", "on", "yes" (any case) and "1" as values for true; treats every other non-empty value as false (i.e. parses leniently).

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredBooleanParameter

    public static boolean getRequiredBooleanParameter(javax.servlet.ServletRequest request,
                                                      java.lang.String name)
                                               throws ServletRequestBindingException

  Get a boolean parameter, throwing an exception if it isn't found or 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).

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredBooleanParameters

    public static boolean[] getRequiredBooleanParameters(javax.servlet.ServletRequest request,
                                                         java.lang.String name)
                                                  throws ServletRequestBindingException

  Get an array of boolean parameters, throwing an exception if not found or one 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).

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getStringParameter

    public static java.lang.String getStringParameter(javax.servlet.ServletRequest request,
                                                      java.lang.String name)
                                               throws ServletRequestBindingException

  Get a String parameter, or `null` if not present.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Returns:
    the String value, or `null` if not present
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getStringParameter

    public static java.lang.String getStringParameter(javax.servlet.ServletRequest request,
                                                      java.lang.String name,
                                                      java.lang.String defaultVal)

  Get a String parameter, with a fallback value. Never throws an exception. Can pass a distinguished value to default to enable checks of whether it was supplied.

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
    `defaultVal` - the default value to use as fallback

### getStringParameters

    public static java.lang.String[] getStringParameters(javax.servlet.ServletRequest request,
                                                         java.lang.String name)

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter with multiple possible values

### getRequiredStringParameter

    public static java.lang.String getRequiredStringParameter(javax.servlet.ServletRequest request,
                                                              java.lang.String name)
                                                       throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

### getRequiredStringParameters

    public static java.lang.String[] getRequiredStringParameters(javax.servlet.ServletRequest request,
                                                                 java.lang.String name)
                                                          throws ServletRequestBindingException

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

  Parameters:
    `request` - current HTTP request
    `name` - the name of the parameter
  Throws:
    `ServletRequestBindingException` - a subclass of ServletException, so it doesn't need to be caught

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD