Recently I encountered the usage of the method getAt()
in Java code. It is used to get the data from a URL (which is sent via GET method by form submit). The URL will be like:
http://192.168.27.55/flight/search?n=airchina
The method was used like name=params.getAt("n")
. Then the data was passed to another function by search("n",name)
. Can any one please brief me how it works?
getAt()
in Groovy has special meaning for collections. It allows one to access elements of the collection using the subscript operator .
Here's the documentation for Map
and List
: Map#getAt(key)
List#getAt(index)
Since it's defined to support some syntactic sugar, you don't really see it ever called directly, since it enables you to instead do something like:
Map foo = [bar: 'baz']
assert foo['bar'] == 'baz'
In your particular case with params
, you'd simply use:
params['n']
...to take advantage of getAt()
. Alternatively, you could use:
params.n
// or
params.get('n')
params.n
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.