help on IlegalStateException 关于 HttpServletRequest.getParameterMap()

博主尝试创建一个servlet类来记录用户上一个网页,将页面及变量存于会话中。但在从缓存获取变量并放入request.getParameterMap时,出现java.lang.IllegalStateException错误。原因是getParameterMap返回的Map是不可变的,不能调用put方法。

Hi,
I'm trying to create a servlet class that will remember the previous web page, so that when a person logs in, it will remember the last page that he/she was in.
The way it's done is that every time the user goes on a web page it will store the page with variables (like parameters in a HashMap) in a session.
However, the problem comes when trying to get the variables out of the cache and putting it in the request.getParameterMap.put(key,value) cos i get an the following problem:

java.lang.IllegalStateException: Cannot find message associated with key 'parameterMap.locked'
        at org.apache.catalina.util.ParameterMap.put(ParameterMap.java:212)

Any suggestions/solutions would be most appreciated.

Thanks

Yogesh

help on IlegalStateException

Posted by: Marco Wang on April 28, 2003 in response to Message #80975 0 replies in this thread

Please check ServletRequest's Java doc, the Map returned from an getParameterMap() is immutable:

"an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array."

You just can't call "put" on that.

转载于:https://www.cnblogs.com/xiaotaoliang/archive/2005/03/02/111368.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值