spring post 图片
- @RequestMapping(value = "/post",method = RequestMethod.POST)
- @ResponseBody
- String GPost(@RequestParam("img1") MultipartFile[] img1,@RequestParam("img2") MultipartFile[] img2) throws IOException {
- byte[] bytes1 = img1[0].getBytes();
- byte[] bytes2 = img2[0].getBytes();
- HttpEntity reqEntity = MultipartEntityBuilder.create()
- .addPart("img1", new ByteArrayBody(bytes1, "img1"))
- .addPart("img2", new ByteArrayBody(bytes2, "img2"))
- .build();
- String result="0";
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- HttpPost httppost = new HttpPost("http://1.6.1.192:806/F/Comp");
- httppost.setEntity(reqEntity);
- System.out.println("executing request " + httppost.getRequestLine());
- CloseableHttpResponse response = httpclient.execute(httppost);
- int code = response.getStatusLine().getStatusCode(); // 这个取HTTP状态码。
- if (code == 302) {
- result="302";
- }
- try {
- System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
- HttpEntity resEntity = response.getEntity();
- if (resEntity != null) {
- System.out.println("Response content length: " + resEntity.getContentLength());
- result = EntityUtils.toString(resEntity);
- }
- EntityUtils.consume(resEntity);
- } finally {
- response.close();
- }
- } finally {
- httpclient.close();
- }
- return result;
- }
- }
spring post 图片的更多相关文章
- spring mvc 图片上传,图片压缩、跨域解决、 按天生成文件夹 ,删除,限制为图片代码等相关配置
spring mvc 图片上传,跨域解决 按天生成文件夹 ,删除,限制为图片代码,等相关配置 fs.root=data/ #fs.root=/home/dev/fs/ #fs.root=D:/fs/ ...
- spring boot图片上传至远程服务器并返回新的图片路径
界面上传图片时考虑到可能会有用户的图片名称一致,使用UUID来对图片名称进行重新生成. //UUIDUtils public class UUIDUtils { public static Strin ...
- 【记录】spring boot 图片上传与显示
问题:spring boot 使用的是内嵌的tomcat, 文件上传指定目录时不知道文件上传到哪个地方,不知道访问路径. //部署到服务器的tomcat上时通常使用这种方式request.getSer ...
- ckeditor+jsp+spring配置图片上传
CKEditor用于富文本输入是极好的,它还有一些插件支持扩展功能,其中图片上传就是比较常用到的.本文简单记录我的实现步骤. 1.CKEditor除了提供三种标准版压缩包下载,还可根据自己的需求进行个 ...
- spring官网下载
1.第一步:打开官网:http://projects.spring.io/ 2.第二步:点击“SPRING FRAMEWORK”图片 3.第三步:点击“小猫”图标 4.第四步:拉到页面中部的位置,找到 ...
- spring源码分析之spring-messaging模块详解
0 概述 spring-messaging模块为集成messaging api和消息协议提供支持. 其代码结构为: 其中base定义了消息Message(MessageHeader和body).消息处 ...
- jsp使用${}语法,对应的spring后台使用Model
实现的前提,一定要在jsp文件顶部加上 <%@page isELIgnored="false" %> 如上图${aa}与${bb},是直接使用Model的key值对应的 ...
- springboot 知识点
---恢复内容开始--- 1springBoot项目引入方式, 1,继承自父 project (需要没有付项目才能用,一般我们的项目都会有 父 项目 所以 这种方式不推荐 ,记住有这种方式 就可以了) ...
- 基于Rebound制造绚丽的动画效果-入门篇
基于Rebound制造绚丽的动画效果-入门篇 Rebound是什么? Rebound是一个来自 Facebook 公司的 Java物理和动画库.Rebound spring 模型可用于创建动画,让你感 ...
随机推荐
- Java登陆拦截器
package com.beidou.warehouseerp.interceptor; import com.alibaba.fastjson.JSON; import com.beidou.war ...
- JavaWeb快速入门
孙卫琴老师的javaweb一书已经买了很多年,由于很厚一直也没有去好好阅读下, 项目发布后有闲暇时间,决定快速学习了,毕竟很多概念和知识主要还是复习. 对于互联网,我们可以简单认为浏览器就是会人类语言 ...
- ArduinoYun教程之OpenWrt-Yun与CLI配置Arduino Yun
ArduinoYun教程之OpenWrt-Yun与CLI配置Arduino Yun OpenWrt-Yun OpenWrt-Yun是基于OpenWrt的一个Linux发行版.有所耳闻的读者应该听说他是 ...
- hdu 5652 India and China Origins(二分+bfs || 并查集)BestCoder Round #77 (div.2)
题意: 给一个n*m的矩阵作为地图,0为通路,1为阻碍.只能向上下左右四个方向走.每一年会在一个通路上长出一个阻碍,求第几年最上面一行与最下面一行会被隔开. 输入: 首行一个整数t,表示共有t组数据. ...
- bzoj 1171 并查集优化顺序枚举 | 线段树套单调队列
详见vfleaking在discuss里的题解. 收获: 当我们要顺序枚举一个序列,并且跳过某些元素,那么我们可以用并查集将要跳过的元素合并到一起,这样当一长串元素需要跳过时,可以O(1)跳过. 暴力 ...
- bzoj 3285 离散对数解指数方程
/************************************************************** Problem: 3285 User: idy002 Language: ...
- git 撤销本地修改
git checkout file 例如:git checkout app/views/carts/_index_m.html.erb 可以先用 git status 查看差异 然后 git chec ...
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划
E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...
- AspNetPager 控件使用
使用方法: 1.添加对AspNetPager.dll的引用 2.在页面上拖放控件 3. <%@ Register assembly="AspNetPager" namespa ...
- DMA Stream/Channel Outputting via GPIOC[0..7]
Ok, so quickly mashing up another example using a different TIM, DMA Stream/Channel for illustration ...