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对象复制到另一个域空间里。
参考:
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的更多相关文章
- Java Web 修改请求参数
方法一.继承 HttpServletRequestWrapper , 实现自定义 request 1.除了修改的参数,其他 Header 等参数不变, 等同于修改了请求参数 2.实质是另一个请求 /* ...
- odoo软件名称及授权协议的变化
先看一张表格 起步时叫TinyERP,微小的ERP:发展中期叫做OpenERP,开放的ERP:历经10年积累的软件,客户群,开发支持用户群,开始构筑自己的商业模式.到8版本,改名为Odoo.同时,软件 ...
- CMSIS-SVD Reference
http://www.keil.com/pack/doc/cmsis/svd/html/modules.html SVD File Schema Levels Device Level Periphe ...
- 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 ...
- 谁说ParameterMap只能读不能写?
开发过javaweb项目的同学,应该都接触过ServeltRequest吧?ServletRequest接口中有一个方法叫做getParameterMap(),他会返回一个Map<String, ...
- IIS7.5上的REST服务的Put,Delete操作发生HTTP Error 405.0 - Method Not Allowed 解决方法
WebDAV 是超文本传输协议 (HTTP) 的一组扩展,为 Internet 上计算机之间的编辑和文件管理提供了标准.利用这个协议用户可以通过Web进行远程的基本文件操作,如拷贝.移动.删除等.在I ...
- [解决方案]CREATE DATABASE statement not allowed within multi-statement transaction.
CREATE DATABASE statement not allowed within multi-statement transaction. 刚开始报这个错误的时候,我上度娘搜了一下. 别人是在 ...
- SharePoint 2016 配置向导报错 - The 'ListInternal' attribute is not allowed
前言 配置SharePoint 2016的配置向导中,第三步创建配置数据库报错,然后百度.谷歌了一下,都没有解决,自己看日志搞定,也许会有人遇到类似问题,分享一下. 1.配置向导的错误截图,如下图: ...
- ORA-28000: the account is locked 账户被锁
这种情况可能是因为你输入错误的用户名密码达到10次,oracle给你锁住了. 解决方法: 首先 ~bash$ sqlplus /nolog SQL> conn sys/sys as sysdba ...
随机推荐
- JS实现冒泡排序,插入排序和快速排序(从input中获取内容)
以前参加面试的时候,被问到过让用JS实现一个快速排序,当时太年轻,并没有回答上来. 于是,这里便把三种排序都用JS来做了一下.结合html,从input文本框中获取输入进行排序. 关于这几种算法的原理 ...
- jQuery Validation Plugin学习
http://blog.csdn.net/violet_day/article/details/14109261 jQuery Validation Plugin Demo 一.默认校验规则 (1)r ...
- android下面的文案重用
尽可能地在xml中建立各种索引,建立映射表,而不是直接每次索引,这对于大规模的文字变动来说是极有好处的.
- MVC中如何在controller的action中输出JS到页面上
MVC中如何在controller的action中输出JS到页面上 可以通过Http上下文对象(httpContext)就可以了,在Action中的HttpContext就是这个Action所指向的页 ...
- php常用正则表达式函数
执行一个正则表达式匹配: preg_match($pattern, $subject, [array &$matches]); 最多匹配一次,返回值0或1,把第一次匹配到的结果放入$match ...
- IOC主要接口
- sql中truncate 、delete与drop区别
SQL truncate .delete与drop区别 相同点: 1.truncate和不带where子句的delete.以及drop都会删除表内的数据. 2.drop.truncate都是DDL ...
- ubuntu基本使用
sudo nautilus xxx指定目录去打开 这个命令就是以root权限打开一个窗口,来管理文件
- nodejs中间层现实
初次接触nodejs,是一种非常神奇的东西,未来必火起来.个人觉得最大优势npm命令. 闲话少说,直入主题.这是一个博客项目,php最为服务端,提供数据给node:nodejs+express作为中间 ...
- 在ECSHOP首页今日特价(促销商品)增加倒计时效果
看到不少朋友在找首页特价商品倒计时的修改方法,写了这篇文章希望能帮到有此需要的朋友们 1.首先修改程序部分 打开includes/lib_goods.php 找到get_promote_goods() ...