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

推荐订阅源

P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
Latest news
Latest news
F
Full Disclosure
T
Tenable Blog
T
Troy Hunt's Blog
The Last Watchdog
The Last Watchdog
S
Secure Thoughts
L
LangChain Blog
有赞技术团队
有赞技术团队
Project Zero
Project Zero
Cloudbric
Cloudbric
爱范儿
爱范儿
GbyAI
GbyAI
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
The Exploit Database - CXSecurity.com
S
Security @ Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
C
Cisco Blogs
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V2EX - 技术
V2EX - 技术
Engineering at Meta
Engineering at Meta
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
The Hacker News
The Hacker News
V
V2EX
F
Fortinet All Blogs
L
LINUX DO - 最新话题
Cisco Talos Blog
Cisco Talos Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News | PayPal Newsroom
博客园 - 三生石上(FineUI控件)
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 南郭先生kaka

待处理数据的两种模型 nginx重启无法找到PId的解决办法 Wiki版产品需求---产品需求文档到底是谁的?产品到底是谁的? 为什么说private方法是有罪的 XML2JSON 的【net.sf.json.JSONException: nu.xom.ParsingException must be followed by either attribute specifications, ">" or "/>"】问题解决办法 继承的第一原则 致那些不甘寂寞的人 上传File时,浏览器总是添加<pre>的解决办法 使用XSLT转换XML2XML WITH AS SQL语句的用法 【Code Style】多余判断 java.lang.NoClassDefFoundError错误 Spring 中Quartz配置数据库化 FactoryBean在XML中的依赖注入方法 Camel FTP中文目录解决办法 配置CentOS6.3 NFS Bean复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier) 重读《目标》---目标 重读《目标》---序
Java 模拟 Http Post
南郭先生kaka · 2013-05-15 · via 博客园 - 南郭先生kaka

     因为某些原因,需要模拟Http post,向服务器进行提交数据。自己琢磨了很多种方法,什么ajax模拟,什么注入啊,想想都太高级了,自己也不太懂,于是想了想,咱也是java程序员,还是找个java的,这样应用起来也是得心应手了。于是施展了baidu和google大法,直接找到了一个开箱即用的模拟方法。我进行了简单的修改。具体代码如下:

 1 public class HttpPostSimulator {
 2     public static void post() throws IOException {
 3 
 4         URL url = new URL("http://a.b.com/dda/updateCCC.action");
 5         URLConnection connection = url.openConnection();
 6         connection.setDoOutput(true);
 7         OutputStreamWriter out = new OutputStreamWriter(
 8                 connection.getOutputStream(), "utf-8");
 9         
10         // post的数据
11         out.write("s.code=de0947&s.typeCode=ccc"); 
12 // 向页面传递数据。post的关键所在!
13         out.flush();
14         out.close();
15         
16         // 一旦发送成功,用以下方法就可以得到服务器的回应:
17         String sCurrentLine;
18         String sTotalString;
19         sCurrentLine = "";
20         sTotalString = "";
21         // 传说中的三层包装阿!
22         BufferedReader resultReader = new BufferedReader(new InputStreamReader(
23                 connection.getInputStream()));
24         while ((sCurrentLine = resultReader.readLine()) != null) {
25             sTotalString += sCurrentLine + "\r\n";
26 
27         }
28         System.out.println(sTotalString);
29 
30     }
31 
32     public static void main(String[] args) throws IOException {
33         post();
34     }
35 }

   参考的地址: 

Java模拟Post 提交表单数据

http://blog.csdn.net/kalision/article/details/7920908