问题描述
两者之间有什么区别
- 对象放置(可序列化键,对象值)
- 无效添加(可序列化的键,对象值)
JSF中StateHelper中的方法?
methods in StateHelper in JSF?
推荐答案
我发现api文档对自己没有帮助,并对其进行了调查.每次调用add时,都会将另一个值附加到列表中,该列表保存在给定键下.如果调用该键上的get,则会返回一个列表.使用add方法可以节省创建列表的时间,并可以监视极端情况,例如.在键为空时创建列表.
I found the api documentation not that helpful myself and investigated it. Each time add is called it appends another value to a list which is saved under the given key. If you call a get on that key you get back a list. The add method saves you creating that list and watches for corner cases, ex. creating the list when the key is empty.
您提到的看跌期权的工作方式类似于类似地图的看跌期权.它将值保存在键下.
The put you mentioned works similar to a map-like put. It saves a value under a key.
相比之下,有一个带有3个参数的重载看跌期权.它在该键下创建一个地图,并使用另一对键/值在该地图上进行放置.再次,获得钥匙会给你一张地图.
In contrast, there is an overloaded put with 3 parameters. It creates a map under that key and does a put on that map with another pair of key/value. Again, a get on the key gives you a map.
基本上,这就是添加和放置工作的方式.还有更多的事情要使部分状态起作用.总结一下:当您想在一个键下添加多个值时,可以使用add.放置2个参数可让您获得类似地图的行为.带有3个参数的位置可让您在一个按键下填充地图.
Thats basically how add and put work. There is some more going on to make partial states working. To sum it up: when you want to add several values under a key you can use add. put with 2 parameters gives you map-like behavior. put with 3 parameters allows you to fill a map under a key.
这篇关于JSF 2中statehelper中的put和add方法之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!