Added a getParameter() that returns a default string if the desired parameter
is not specified. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1720 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -56,7 +56,6 @@ public class ParameterUtil
|
||||
String value = req.getParameter(name);
|
||||
if (value == null) {
|
||||
return returnNull ? null : "";
|
||||
|
||||
} else {
|
||||
return value.trim();
|
||||
}
|
||||
@@ -74,7 +73,6 @@ public class ParameterUtil
|
||||
{
|
||||
return parseFloatParameter(
|
||||
getParameter(req, name, false), invalidDataMessage);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +87,6 @@ public class ParameterUtil
|
||||
{
|
||||
return parseIntParameter(
|
||||
getParameter(req, name, false), invalidDataMessage);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,6 +161,17 @@ public class ParameterUtil
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the supplied parameter from the request. If the parameter does
|
||||
* not exist, <code>defval</code> is returned.
|
||||
*/
|
||||
public static String getParameter (
|
||||
HttpServletRequest req, String name, String defval)
|
||||
{
|
||||
String value = req.getParameter(name);
|
||||
return StringUtil.blank(value) ? defval : value.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the supplied parameter from the request and converts it to
|
||||
* an integer. If the parameter does not exist, <code>defval</code> is
|
||||
|
||||
Reference in New Issue
Block a user