web.xml中:

<!-- 用户put提交参数 -->
<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>


<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/conf/*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

 

Controller中:

@RequestMapping(value="/{userId}",method = RequestMethod.PUT)

 

测试的main方法中:

String putStr="http://192.168.1.8:8080/xxx/users/36";
try {
HttpPut method = new HttpPut(putStr);
method.setHeader("serverType", "0"); List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("orgId", "10"));
params.add(new BasicNameValuePair("userName", "bbbddd_001"));
params.add(new BasicNameValuePair("email", "liwy@xxx.cn"));
params.add(new BasicNameValuePair("phoneNo", "111222")); method.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = client.execute(method);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity, "UTF-8");
System.out.println(result);
} catch (IOException e) { e.printStackTrace();
}

 

 

客户端进行http请求时用到的jar

ezmorph-1.0.6.jar
fluent-hc-4.5.1.jar
httpclient-4.5.1.jar
httpclient-cache-4.5.1.jar
httpclient-win-4.5.1.jar
httpcore-4.4.3.jar
httpmime-4.5.1.jar
jna-4.1.0.jar
jna-platform-4.1.0.jar

spring mvc 接收 put参数的更多相关文章

  1. 【spring mvc】后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface

    后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate ...

  2. 如何让Spring MVC接收的参数可以转换为java对象

    场景: web.xml中增加了一个DispatcherServlet配置,并在同级目录下添加了**-servlert.xml文件,搭建起了一个spring mvc的restful访问接口. 问题描述: ...

  3. spring mvc接收http参数

    1.http协议携带参数,无外乎两个三个存储地点:1.url上 ,2.header里 3.body里. 2.get请求是没有body的,数据全都放在url上,以?xx&xxx形式.注:get请 ...

  4. Spring MVC 接收前端参数的方式

    方式一: 普通方式接收 1 @RequestMapping("/index") 2 public String getUserName(String username) { 3 S ...

  5. 使用Spring mvc接收整个url地址及参数时注意事项

    使用Spring mvc接收整个url地址及参数时注意事项:url= http://baidu?oid=9525c1f2b2cd45019b30a37bead6ebbb&td=2015-08- ...

  6. Spring MVC接收参数(Map,List,JSON,Date,2个Bean)(记录一次面试惨状)

    题目Spring MVC 接收参数 MapListDate2个BeanJSON Spring MVC接收参数 -Map Spring MVC接收参数 -List Spring MVC接收参数 -dat ...

  7. Spring MVC url提交参数和获取参数

    [转载:http://blog.csdn.net/mahoking] 普通URL提交参数         该格式url为:url.do?param1=mahc&param2=8888.00 需 ...

  8. spring mvc获取路径参数的几种方式 - 浅夏的个人空间 - 开源中国社区

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  9. spring mvc接收ajax提交的JSON数据,并反序列化为对象

    需求:spring mvc接收ajax提交的JSON数据,并反序列化为对象,代码如下: 前台JS代码: //属性要与带转化的对象属性对应 var param={name:'语文',price:16}; ...

随机推荐

  1. Centos7下使用yum安装lnmp zabbix3.2

    1:配置epel-release mysql zabbix 源 配置epel源 wget http://mirrors.aliyun.com/epel/epel-release-latest-7.no ...

  2. java web 机试

    经过近一个月的学习,我们的java web已经学习完了. 这是我们这次的机试题. 一:题目 请利用MVC设计模式,并使用JSP.Servlet.JSTL和JQuery等技术实现动态条件的分页显示查询. ...

  3. 读jQuery源码释疑笔记2

    本释疑笔记是针对自己在看源码的过程中遇到的一些问题的解答,对大众可能不具有参考性,不过可以看看有没有你也不懂得地方,相互学习,相互进步. 1.函数init <div id="one&q ...

  4. 异步上传文件,jquery+ajax,显示进度条

    根据网上的资料,做了很多修改,结果发现使用ajax上传数据时若要监听xhr.upload.addEventListener("progress",functiion(e),fals ...

  5. 并发编程之 LinkedBolckingQueue 源码剖析

    前言 JDK 1.5 之后,Doug Lea 大神为我们写了很多的工具,整个 concurrent 包基本都是他写的.也为我们程序员写好了很多工具,包括我们之前说的线程池,重入锁,线程协作工具,Con ...

  6. 数据库中存储日期的字段类型到底应该用varchar还是datetime

    将数据库中存储时间的数据类型改为varchar(),这时最好让这些时间是数据库中自动生成的(一个没有格式的输入也可能会导致输出错误),因为存储类型为varchar(),所以获取到的值也就被认为是一个字 ...

  7. C# Hadoop学习笔记(一)—环境安装

    一.安装环境 1,前期准备:官网下载“NuGet Package Manager”,按自己已有的VS环境下载对应版本: 2,利用NuGet下载Hadoop For .NET SDK,地址“http:/ ...

  8. 使用HtmlAgilityPack抓取Ethereum Tokens信息

    使用HtmlAgilityPack抓取Ethereum Tokens信息 class Program { static void Main(string[] args) { try { for (in ...

  9. CSS 样式属性

    大小 width   宽               body {   min-width:1200px; height  高                      }               ...

  10. 什么是 Spring AOP 和代理

    https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_9403056301388627935% ...