火星文 技术研习社

Noname Cat, Keep Thinking
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

会自动实现 add 或 replace 功能。

在 JSP 页面中,从 page/application/request/session 中 getAttribute 出来的对象是原对象的一次地址引用,因此之后进行的任何更改,例如 map 的 put、remove 等操作是直接对 application/request/session 中的原对象进行操作,不需要 set 回去即可自动更新(或不能更新,视对象行为而定)。

在 JSP TAG 中,从 page/application/request/session 中 getAttribute 出来的对象是原对象的一次值引用,因此之后做了任何更改之后都要 set 回去,并不能自动更新。

用 request.getParameterMap() 获得的 map,在试图对其元素进行修改时会抛出如下异常:
java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap