惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Last Week in AI
Last Week in AI
罗磊的独立博客
G
Google Developers Blog
Y
Y Combinator Blog
博客园 - 【当耐特】
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
美团技术团队
宝玉的分享
宝玉的分享
Jina AI
Jina AI
小众软件
小众软件
T
Tailwind CSS Blog
A
About on SuperTechFans

博客园 - 上校

gitea设置 在Cocos Creator 项目里安装 cocos-mcp-server nginx安装教程 nacos安装教程 minio安装教程 GIT笔记 CC教程 芋道笔记 SpringCloud MySqlSugar常用写法 linux查找大目录和大文件 .NET代码混淆——开源.net 混淆器ConfuserEx介绍 微软云SQL数据库创建只读用户 nginx配置ssl证书实现https访问 nexus搭建私服 Linux下创建用户并设置权限 ActiveMQ修改密码 shiro源码篇 - shiro的session共享,你值得拥有 google guava Docker虚拟化管理:30分钟教你学会用Docker Shiro结合Redis实现分布式或集群环境下的Session共享 Springboot整合redis spring boot2整合shiro安全框架实现前后端分离的JWT token登录验证 scp命令 Linux和Windows文件互传
http post
上校 · 2020-04-08 · via 博客园 - 上校
    public static boolean sendPostRequest(String path, String data) throws Exception{
//        StringBuilder sb = new StringBuilder();
//        if (params != null && !params.isEmpty()) {
//            for (Map.Entry<String, String> entry : params.entrySet()) {
//                sb.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), enc)).append('&');
//            }
//            sb.deleteCharAt(sb.length() - 1);
//        }
        byte[] entitydata = data.getBytes();//得到实体的二进制数据
        URL url = new URL(path);
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        conn.setRequestMethod("POST");
        conn.setConnectTimeout(5 * 1000);
        conn.setDoOutput(true);//如果通过post提交数据,必须设置允许对外输出数据
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("Content-Length", String.valueOf(entitydata.length));
        OutputStream outStream = conn.getOutputStream();
        outStream.write(entitydata);
        outStream.flush();
        outStream.close();
        if(conn.getResponseCode()==200){
            return true;
        }
        return false;
    }