错误:java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap

at org.apache.catalina.util.ParameterMap.remove(ParameterMap.java:205)

1.Servlet中使用了这个方法:request.getParameterMap(),将它的返回值赋值给一个空的hashmap对象结果报错。参考:

it looks like you are trying to *modify* the > received form parameters Map, which under Tomcat's interpretation of > HTTP request handling is a no-no. (The Servlet Spec 3.0 does not > explicitly say so (Chapter 3), but strongly hints in that direction > (there are only "get" methods, no "set" ones).

貌似Servlet规范隐晦的告诉了我们这点。

The relevant info is in the Javadoc for ServletRequest#getParameterMap(). It states quite clearly that the parameter map is immutable.

这个方法的返回值是不可变的。

作者还说一些关键信息却只能在javadoc里找到真是令人抓狂啊~

2.解决方法是:new HashMap(request.getParameterMap())

因为直接用等好赋值只是地址引用,并未改变内存空间,因此无法对之前产生的那个被锁定的map对象进行操作,而使用new方法确实重新申请了内存地址,将该“不可变”的map对象复制到另一个域空间里。

参考:

1.http://goo.gl/pvweu

2.http://goo.gl/AEvPN

https://my.oschina.net/cwalet/blog/35431

不能被修改的原因:

org.apache.catalina.util.ParameterMap

 /**
* Associate the specified value with the specified key in this map. If
* the map previously contained a mapping for this key, the old value is
* replaced.
*
* @param key Key with which the specified value is to be associated
* @param value Value to be associated with the specified key
*
* @return The previous value associated with the specified key, or
* <code>null</code> if there was no mapping for key
*
* @exception IllegalStateException if this map is currently locked
*/
@Override
public V put(K key, V value) { if (locked)
throw new IllegalStateException
(sm.getString("parameterMap.locked"));
return (super.put(key, value)); }

No modifications are allowed to a locked ParameterMap的更多相关文章

  1. Java Web 修改请求参数

    方法一.继承 HttpServletRequestWrapper , 实现自定义 request 1.除了修改的参数,其他 Header 等参数不变, 等同于修改了请求参数 2.实质是另一个请求 /* ...

  2. odoo软件名称及授权协议的变化

    先看一张表格 起步时叫TinyERP,微小的ERP:发展中期叫做OpenERP,开放的ERP:历经10年积累的软件,客户群,开发支持用户群,开始构筑自己的商业模式.到8版本,改名为Odoo.同时,软件 ...

  3. CMSIS-SVD Reference

    http://www.keil.com/pack/doc/cmsis/svd/html/modules.html SVD File Schema Levels Device Level Periphe ...

  4. English Learning -- 0611--When Burnout Is a Sign You Should Leave Your Job

    I like the following article from Harvard Business Review, as I ever experienced burnout at work. Ve ...

  5. 谁说ParameterMap只能读不能写?

    开发过javaweb项目的同学,应该都接触过ServeltRequest吧?ServletRequest接口中有一个方法叫做getParameterMap(),他会返回一个Map<String, ...

  6. IIS7.5上的REST服务的Put,Delete操作发生HTTP Error 405.0 - Method Not Allowed 解决方法

    WebDAV 是超文本传输协议 (HTTP) 的一组扩展,为 Internet 上计算机之间的编辑和文件管理提供了标准.利用这个协议用户可以通过Web进行远程的基本文件操作,如拷贝.移动.删除等.在I ...

  7. [解决方案]CREATE DATABASE statement not allowed within multi-statement transaction.

    CREATE DATABASE statement not allowed within multi-statement transaction. 刚开始报这个错误的时候,我上度娘搜了一下. 别人是在 ...

  8. SharePoint 2016 配置向导报错 - The 'ListInternal' attribute is not allowed

    前言 配置SharePoint 2016的配置向导中,第三步创建配置数据库报错,然后百度.谷歌了一下,都没有解决,自己看日志搞定,也许会有人遇到类似问题,分享一下. 1.配置向导的错误截图,如下图: ...

  9. ORA-28000: the account is locked 账户被锁

    这种情况可能是因为你输入错误的用户名密码达到10次,oracle给你锁住了. 解决方法: 首先 ~bash$ sqlplus /nolog SQL> conn sys/sys as sysdba ...

随机推荐

  1. PHP计算2点经纬度之间的距离

    hp] view plaincopy function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longit ...

  2. .NET Entity Framework入门简介及简单操作

    Entity Framework是微软借鉴ORM思想开发自己的一个ORM框架. ORM就是将数据库表与实体对象(相当于三层中的Model类)相互映射的一种思想. 最大的优点就是非常方便的跨数据库平台. ...

  3. weblogic9.2重置密码

    1.删除DefaultAuthenticatorInit.ldift 2.执行命令:java -cp /home/weblogic/bea/weblogic92/server/lib/weblogic ...

  4. ASP.NET跨页面传值技巧

      1 使用QueryString变量    QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中.如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用  ...

  5. easyui-helloworld

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. GIS科研站

    http://www.3sbase.com/3sbase/ 近年来,地理信息科学发展迅猛,科研人员日益增多,但目前尚缺乏良好的交流平台,致使优秀的科研成果难以推广.同时,对于大量的GIS学生而言,对国 ...

  7. Codeforces Round #299 (Div. 1)

    Problem A: 实际上对于一段数字假设和为k,每次取较大的m个进行t次减一操作,最多减去的是min(m*t,k). 明白了这个结论就可以直接二分答案了. #include <bits/st ...

  8. ubuntu zendDebugger.so 加载不上的问题

    参考文章   http://blog.sina.com.cn/s/blog_6612d5810101dapf.html 装zenDdebugger是为了在eclipse中调试用!!!!!!!结果搞了半 ...

  9. SQLite学习第01天:参考资料

    今天开始学习数据库相关的知识,由于本人从事的是嵌入式软件开发方向,所以在数据库的选择时就果断选择了SQLite,在网上搜索了一下相关的资料并且配置好了环境.首先,想要对SQLite有一个基本的了解还是 ...

  10. How to say all the keyboard symbols in English and Chinese

    How to say all the keyboard symbols in English Symbol English 中文 ~ tilde 波浪号 ` grave accent, backquo ...