类 PortletRequestUtils
- java.lang.Object
- org.springframework.web.portlet.bind.PortletRequestUtils
public abstract class PortletRequestUtils extends 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.
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, Keith Donald, John A. Lewis
构造器概要
构造器 构造器 说明 PortletRequestUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Boolean
getBooleanParameter(PortletRequest request, String name)
Get a Boolean parameter, ornull
if not present.static boolean
getBooleanParameter(PortletRequest request, String name, boolean defaultVal)
Get a boolean parameter, with a fallback value.static boolean[]
getBooleanParameters(PortletRequest request, String name)
Get an array of boolean parameters, return an empty array if not found.static Double
getDoubleParameter(PortletRequest request, String name)
Get a Double parameter, ornull
if not present.static double
getDoubleParameter(PortletRequest request, String name, double defaultVal)
Get a double parameter, with a fallback value.static double[]
getDoubleParameters(PortletRequest request, String name)
Get an array of double parameters, return an empty array if not found.static Float
getFloatParameter(PortletRequest request, String name)
Get a Float parameter, ornull
if not present.static float
getFloatParameter(PortletRequest request, String name, float defaultVal)
Get a float parameter, with a fallback value.static float[]
getFloatParameters(PortletRequest request, String name)
Get an array of float parameters, return an empty array if not found.static Integer
getIntParameter(PortletRequest request, String name)
Get an Integer parameter, ornull
if not present.static int
getIntParameter(PortletRequest request, String name, int defaultVal)
Get an int parameter, with a fallback value.static int[]
getIntParameters(PortletRequest request, String name)
Get an array of int parameters, return an empty array if not found.static Long
getLongParameter(PortletRequest request, String name)
Get a Long parameter, ornull
if not present.static long
getLongParameter(PortletRequest request, String name, long defaultVal)
Get a long parameter, with a fallback value.static long[]
getLongParameters(PortletRequest request, String name)
Get an array of long parameters, return an empty array if not found.static boolean
getRequiredBooleanParameter(PortletRequest request, String name)
Get a boolean parameter, throwing an exception if it isn't found or isn't a boolean.static boolean[]
getRequiredBooleanParameters(PortletRequest request, String name)
Get an array of boolean parameters, throwing an exception if not found or one isn't a boolean.static double
getRequiredDoubleParameter(PortletRequest request, String name)
Get a double parameter, throwing an exception if it isn't found or isn't a number.static double[]
getRequiredDoubleParameters(PortletRequest request, String name)
Get an array of double parameters, throwing an exception if not found or one is not a number.static float
getRequiredFloatParameter(PortletRequest request, String name)
Get a float parameter, throwing an exception if it isn't found or isn't a number.static float[]
getRequiredFloatParameters(PortletRequest request, String name)
Get an array of float parameters, throwing an exception if not found or one is not a number.static int
getRequiredIntParameter(PortletRequest request, String name)
Get an int parameter, throwing an exception if it isn't found or isn't a number.static int[]
getRequiredIntParameters(PortletRequest request, String name)
Get an array of int parameters, throwing an exception if not found or one is not a number..static long
getRequiredLongParameter(PortletRequest request, String name)
Get a long parameter, throwing an exception if it isn't found or isn't a number.static long[]
getRequiredLongParameters(PortletRequest request, String name)
Get an array of long parameters, throwing an exception if not found or one is not a number.static String
getRequiredStringParameter(PortletRequest request, String name)
Get a String parameter, throwing an exception if it isn't found or is empty.static String[]
getRequiredStringParameters(PortletRequest request, String name)
Get an array of String parameters, throwing an exception if not found or one is empty.static String
getStringParameter(PortletRequest request, String name)
Get a String parameter, ornull
if not present.static String
getStringParameter(PortletRequest request, String name, String defaultVal)
Get a String parameter, with a fallback value.static String[]
getStringParameters(PortletRequest request, String name)
Get an array of String parameters, return an empty array if not found.
构造器详细资料
PortletRequestUtils
public PortletRequestUtils()
方法详细资料
getIntParameter
public static Integer getIntParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get an Integer parameter, ornull
if not present. Throws an exception if it the parameter value isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 返回:
- the Integer value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getIntParameter
public static int getIntParameter(PortletRequest request, 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.- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getIntParameters
public static int[] getIntParameters(PortletRequest request, String name)
Get an array of int parameters, return an empty array if not found.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredIntParameter
public static int getRequiredIntParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get an int parameter, throwing an exception if it isn't found or isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredIntParameters
public static int[] getRequiredIntParameters(PortletRequest request, String name) throws PortletRequestBindingException
Get an array of int parameters, throwing an exception if not found or one is not a number..- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getLongParameter
public static Long getLongParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a Long parameter, ornull
if not present. Throws an exception if it the parameter value isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 返回:
- the Long value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getLongParameter
public static long getLongParameter(PortletRequest request, 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.- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getLongParameters
public static long[] getLongParameters(PortletRequest request, String name)
Get an array of long parameters, return an empty array if not found.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredLongParameter
public static long getRequiredLongParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a long parameter, throwing an exception if it isn't found or isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredLongParameters
public static long[] getRequiredLongParameters(PortletRequest request, String name) throws PortletRequestBindingException
Get an array of long parameters, throwing an exception if not found or one is not a number.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getFloatParameter
public static Float getFloatParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a Float parameter, ornull
if not present. Throws an exception if it the parameter value isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 返回:
- the Float value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getFloatParameter
public static float getFloatParameter(PortletRequest request, 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.- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getFloatParameters
public static float[] getFloatParameters(PortletRequest request, String name)
Get an array of float parameters, return an empty array if not found.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredFloatParameter
public static float getRequiredFloatParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a float parameter, throwing an exception if it isn't found or isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredFloatParameters
public static float[] getRequiredFloatParameters(PortletRequest request, String name) throws PortletRequestBindingException
Get an array of float parameters, throwing an exception if not found or one is not a number.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getDoubleParameter
public static Double getDoubleParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a Double parameter, ornull
if not present. Throws an exception if it the parameter value isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 返回:
- the Double value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getDoubleParameter
public static double getDoubleParameter(PortletRequest request, 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.- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getDoubleParameters
public static double[] getDoubleParameters(PortletRequest request, String name)
Get an array of double parameters, return an empty array if not found.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredDoubleParameter
public static double getRequiredDoubleParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a double parameter, throwing an exception if it isn't found or isn't a number.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredDoubleParameters
public static double[] getRequiredDoubleParameters(PortletRequest request, String name) throws PortletRequestBindingException
Get an array of double parameters, throwing an exception if not found or one is not a number.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getBooleanParameter
public static Boolean getBooleanParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a Boolean parameter, ornull
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 portlet requestname
- the name of the parameter- 返回:
- the Boolean value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getBooleanParameter
public static boolean getBooleanParameter(PortletRequest request, 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).
- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getBooleanParameters
public static boolean[] getBooleanParameters(PortletRequest request, 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).
- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredBooleanParameter
public static boolean getRequiredBooleanParameter(PortletRequest request, String name) throws PortletRequestBindingException
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).
- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredBooleanParameters
public static boolean[] getRequiredBooleanParameters(PortletRequest request, String name) throws PortletRequestBindingException
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).
- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getStringParameter
public static String getStringParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a String parameter, ornull
if not present. Throws an exception if it the parameter value is empty.- 参数:
request
- current portlet requestname
- the name of the parameter- 返回:
- the String value, or
null
if not present - 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getStringParameter
public static String getStringParameter(PortletRequest request, String name, 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.- 参数:
request
- current portlet requestname
- the name of the parameterdefaultVal
- the default value to use as fallback
getStringParameters
public static String[] getStringParameters(PortletRequest request, String name)
Get an array of String parameters, return an empty array if not found.- 参数:
request
- current portlet requestname
- the name of the parameter with multiple possible values
getRequiredStringParameter
public static String getRequiredStringParameter(PortletRequest request, String name) throws PortletRequestBindingException
Get a String parameter, throwing an exception if it isn't found or is empty.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught
getRequiredStringParameters
public static String[] getRequiredStringParameters(PortletRequest request, String name) throws PortletRequestBindingException
Get an array of String parameters, throwing an exception if not found or one is empty.- 参数:
request
- current portlet requestname
- the name of the parameter- 抛出:
PortletRequestBindingException
- a subclass of PortletException, so it doesn't need to be caught