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

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2022-01-03
  • 2021-06-18
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2022-02-07
  • 2021-05-17
  • 2022-03-09
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案