首页 > 代码库 > Firefox使用Poster插件发送post请求

Firefox使用Poster插件发送post请求

目的:验证http请求功能正确与否,需要发送post,get请求,则可以使用Poster插件方便简单。

自我总结,有什么改正的地方请指出,感激不尽!

 

1.安装Poster插件。

点击firefox右上方的菜单键-->[ 附加组件 ],在搜索框中输入poster点击安装即可

 

提示重启Firefox,才能用,重启后,在上方菜单栏[ 工具 ]-->即可看到[ Poster ]选项,说明已安装成功。

 

 

 

 

 

 

 

 

 

2.创建一个maven项目"getpost",将war放入tomcat

  1). 在webapp目录下创建一个html文件:test.html

  2). 表单action跳转路径为同级目录下的index.jsp

  3).打成war包放入tomcat

  test.html

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Insert title here</title></head><body>    <form name="Login" method="post" action="index.jsp">        User ID: <input type="text" name="name"><br>         Password: <input type="password" name="password">         <input type="HIDDEN" name="from" value="welcome">          <input type="submit" value="submit">    </form></body></html>

  index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"    pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><%    response.setContentType("text;html;charset=utf-8");    String username=request.getParameter("name");    String password=request.getParameter("password");    System.out.println("username="+username);    System.out.println("password="+password);    System.out.println("servlet test success....");%>Success!</body></html>

 

 

3.验证

浏览器测试:http://localhost:8989/getpost/test.html,能正常挑战到index.jsp,显示hello word。

Poster测试:

打开firebug,看到该post请求的参数

 

 

 

 

 

 

 

 

 

 

将请求的URL,和参数填写到Poster中

 

 点击Body from Parameters按钮即可。

 

点击中间的"post"按钮,若弹出的对话框,为回应页面的内容则模拟post的请求成功。

 

总结:Poster插件不仅仅能发post请求,其他请求也能发。发送http请求也不止Poster这一种方式。

 

Firefox使用Poster插件发送post请求