类 ParameterTool
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.LocaleConfig
org.apache.velocity.tools.generic.FormatConfig
org.apache.velocity.tools.generic.ValueParser
org.apache.velocity.tools.view.ParameterTool
Utility class for easy parsing of ServletRequest parameters.
Template example(s):
$params.foo -> bar
$params.getNumber('baz') -> 12.6
$params.getInt('baz') -> 12
$params.getNumbers('baz') -> [12.6]
Toolbox configuration:
<tools>
<toolbox scope="request">
<tool class="org.apache.velocity.tools.view.ParameterTool"/>
</toolbox>
</tools>
When used as a view tool, this should only be used in the request scope. This class is, however, quite useful in your application's controller, filter, or action code as well as in templates.
- 从以下版本开始:
- VelocityTools 2.0
- 版本:
- $Revision$ $Date$
- 作者:
- Nathan Bubna
-
嵌套类概要
-
字段概要
从类继承的字段 org.apache.velocity.tools.generic.ValueParser
ALLOWSUBKEYS_KEY, DEFAULT_STRINGS_DELIMITER, READONLY_KEY, STRINGS_DELIMITER_FORMAT_KEY从类继承的字段 org.apache.velocity.tools.generic.FormatConfig
DEFAULT_FORMAT, FORMAT_KEY从类继承的字段 org.apache.velocity.tools.generic.LocaleConfig
DEFAULT_LOCALE从类继承的字段 org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
构造器概要
构造器构造器说明Constructs a new instanceParameterTool(jakarta.servlet.ServletRequest request) Constructs a new instance using the specified request. -
方法概要
修饰符和类型方法说明protected voidconfigure(ValueParser values) getAll()protected jakarta.servlet.ServletRequestReturns the currentServletRequestfor this instance.protected MapOverrides ValueParser.getSource() to return the result of getRequest().getParameterMap() and expand singleton arrays within it first.Overrides ValueParser.getValue(String key) to retrieve the value from the ServletRequest instead of an arbitrary Map.Object[]Overrides ValueParser.getValues(String key) to retrieve Strings from the ServletRequest instead of an arbitrary Map.voidsetRequest(jakarta.servlet.ServletRequest request) Sets the currentServletRequestprotected voidOverrides ValueParser.setSource(Map source) to throw an UnsupportedOperationException, because this class uses a servlet request as its source, not a Map.从类继承的方法 org.apache.velocity.tools.generic.ValueParser
clear, containsKey, containsValue, entrySet, exists, get, get, getAllowSubkeys, getBoolean, getBoolean, getBoolean, getBooleans, getDouble, getDouble, getDouble, getDoubles, getInt, getInteger, getInteger, getInts, getLocale, getLocale, getLocales, getLong, getLong, getNumber, getNumber, getNumbers, getReadOnly, getSource, getString, getString, getStrings, getSubkey, getSubkeys, getValue, hasSubkeys, isEmpty, keySet, parseStringList, put, putAll, remove, setAllowSubkeys, setReadOnly, setStringsDelimiter, size, toString, values从类继承的方法 org.apache.velocity.tools.generic.FormatConfig
getFormat, setFormat从类继承的方法 org.apache.velocity.tools.generic.LocaleConfig
getLocale, setLocale, toLocale从类继承的方法 org.apache.velocity.tools.generic.SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
构造器详细资料
-
ParameterTool
public ParameterTool()Constructs a new instance -
ParameterTool
public ParameterTool(jakarta.servlet.ServletRequest request) Constructs a new instance using the specified request.- 参数:
request- theServletRequestto be parsed
-
-
方法详细资料
-
configure
- 覆盖:
configure在类中ValueParser
-
setRequest
public void setRequest(jakarta.servlet.ServletRequest request) Sets the currentServletRequest- 参数:
request- theServletRequestto be parsed
-
getRequest
protected jakarta.servlet.ServletRequest getRequest()Returns the currentServletRequestfor this instance.- 返回:
- the current
ServletRequest - 抛出:
UnsupportedOperationException- if the request is null
-
getValue
Overrides ValueParser.getValue(String key) to retrieve the value from the ServletRequest instead of an arbitrary Map.- 覆盖:
getValue在类中ValueParser- 参数:
key- the parameter's key- 返回:
- parameter matching the specified key or
nullif there is no matching parameter
-
getValues
Overrides ValueParser.getValues(String key) to retrieve Strings from the ServletRequest instead of an arbitrary Map.- 覆盖:
getValues在类中ValueParser- 参数:
key- the key for the desired parameter- 返回:
- an array of String objects containing all of the values
the given request parameter has, or
nullif the parameter does not exist
-
setSource
Overrides ValueParser.setSource(Map source) to throw an UnsupportedOperationException, because this class uses a servlet request as its source, not a Map.- 覆盖:
setSource在类中ValueParser
-
getSource
Overrides ValueParser.getSource() to return the result of getRequest().getParameterMap() and expand singleton arrays within it first.- 覆盖:
getSource在类中ValueParser
-
getAll
- 返回:
- the map of all parameters available for the current request.
-