如何写post请求对ajax post 数据库gbk进行操作

PB 如何实现HTTP协议 并使用get、post方式提交和获取 数据信息
要用pb做一个接口&接口调用方式要求用&http协议的get、post方式实现&来提交和获取数据&对这部分不是很了解&希望大家帮我指点一下~~有没有人做过类似的功能~~
回复讨论(解决方案)
找找websevice&或者
21:07&&&[]
1、GET请求的数据会附在URL之后; 2、GET方式提交的数据最多只能是1024字节,理论上POST没有限制,可传较大量的数据; GET方式URL长度有限制的原因:实际上URL不存在参数上限的问题,HTTP协议规范没有对URL长度进行限制,这个限制是特定的浏览器及服务器对它的限制
21:26&&&[]
HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE、CONNECT 这几种。其中 POST 一般用来向服务端提交数据,本文主要讨论 POST 提交数据的几种方式。我们知道,HTTP 协议是以 ASCII 码传输,建立在
15:14&&&[]
如题,好久没看,忘记了。
回复讨论(解决方案)
有人正好跟你相反,&请看
http://expert.csdn.net/Expert/topic/.xml?temp=.5656244
靠,我要的事编程方式指定。
默认就是了,不用更改,指定什么呀
-10:01&&&[]
设计,所以导致一个比较严重的问题是传统的Web MVC框架基本上都只支持GET和POST两种HTTP方法,而不支持PUT和DELETE方法。 &  * 简单解释一下MVC:MVC本来是存在于Desktop程序中的,M是指数据模型,V是指用户界面,C则是控制器。使用MVC的目的是将M和V的实现
12:42&&&[]
POST方式,怎么提交表单数据?
回复讨论(解决方案)
先在js里获取定义:
var&ids=&yourids&;
var&id&=&5;
xmlhttp.open(&POST&,&quot
13:11&&&[]
工行的开发手册是这么说的
企业按照工行提供的xml包格式进行打包,在局域网内通过http协议以POST方式将交易包发送到NetSafe&Client的安全http协议服务器。
http请求格式:action=”http://客户端NetSafe&Client的地址和加密端口号
17:39&&&[]
最近要实现一个通过Http&以POST方式上传图片的功能,自己写了一个简单的通过HttpWebRequest上传的方法,代码如下
&public&string&UpLoadPhoto(string&filePath,&nbsp
-15:07&&&[]
ajax获取到的id数据,如何通过post方式提交该数据到post页面去。
&form&id=&form1&&name=&form1&&method=&post&&action=&quot
18:25&&&[]
教科书上说,soap影响效率,除非返回dataset或对象时用
建议用&get&post&,但没有说怎么用?
不会是xmlhttp吧?赫赫。。
回复讨论(解决方案)
教科书的意思是否是这样:
如果采用WS,在获取数据时可能比较低效,而此时就不要采用WS
-13:11&&&[]
我在博客园找到个关于post提交数据的代码http:///huizhang212/archive//HttpWebRequest.html&&
但是每次运行到responseCallback中的
16:17&&&[]
方法,后一种情况,应该使用PUT方法。
& & & 也许你会觉得这个两个方法的差别没什么大不了的,用错了也不会有什么问题,但是你的服务一放到internet上,如果不遵从HTTP协议的规范,就可能 给自己带来麻烦。比如,没准Google Crawler也会访问你的服务
16:43&&&[]Http使用post方式提交数据(使用java标准接口) - 推酷
Http使用post方式提交数据(使用java标准接口)
本文内容:使用java标准接口,实现http用post方式提交数据。
-------------------------------------------------------------------------------------------------------------
程序组成部分:
1.客户端用eclipse HttpUtils.java 标准java接口,实现http用post方式提交数据。 (用post方式提交 username 和 password)
2.服务器端用myeclipse+tomcat 对客户端请求进行相应。(若用户名密码正确,则返回字符串&login is success !& ,不正确则返回字符串“login is fail !”)
重点注意点:
1. public static String sendPostMessage(Map&String,String& params , String encode)
&&& 目的: 在客户端向服务器端发送 数据 params , 最终获取从服务器返回的输入流,最终将该输入流转换成字符串。注意使用标准java接口如何实现http的post请求,成功与服务器连接,并且获得从服务器端响应返回的数据。
2. public String String changInputStream(InputStream inputStream , String encode)
&&& 目的: 将一个输入流按照指定编码方式转变成一个字符串。(本例中是指,将从服务器端返回的输入流InputStream转变成一个字符串String,编码方式是encode方式)
3. Map&String ,String& 的实例化方法及迭代方法
& Map& 的实例化方法:
& Map&String, String& params = new HashMap&String, String&();
&&params.put(&username&, &admin&);
&&params.put(&password&, &123&);
&& Map 的迭代方法:
&StringBuffer stringBuffer = new StringBuffer();
&&&for (Map.Entry&String, String& entry : params.entrySet()) {
&&&&&stringBuffer
&&&&&&&.append(entry.getKey())
&&&&&&&.append(&=&)
&&&&&&&.append(URLEncoder.encode(entry.getValue(), encode))
&&&&&&&.append(&&&);
&&&&} catch (UnsupportedEncodingException e) {
&&&&&// TODO Auto-generated catch block
&&&&&e.printStackTrace();
&&&// 删掉最后一个 & 字符
&&&stringBuffer.deleteCharAt(stringBuffer.length() - 1);
----------------------------------------------------------------------------------------------------------------
程序思路:
1. 客户端建立http链接httpURLConnection,使用OutputStream向服务器传入数据
2. 获得从服务器端返回的输入流InputStream
3. 将InputStream转换成字符串String
----------------------------------------------------------------------------------------------------------------
程序运行效果:
1.客户端运行效果
2. 服务器端运行结果
关键代码:
1. 客户端 HttpUtils.java
package com.http.
import java.io.ByteArrayOutputS
import java.io.IOE
import java.io.InputS
import java.io.OutputS
import java.io.UnsupportedEncodingE
import java.net.HttpURLC
import java.net.MalformedURLE
import java.net.URL;
import java.net.URLE
import java.util.HashM
import java.util.M
public class HttpUtils {
// 表示服务器端的url
private static String PATH = &http://192.168.0.100:8080/myhttp/servlet/LoginAction&;
private static URL
public HttpUtils() {
// TODO Auto-generated constructor stub
url = new URL(PATH);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
* params 填写的URL的参数 encode 字节编码
public static String sendPostMessage(Map&String, String& params,
String encode) {
StringBuffer stringBuffer = new StringBuffer();
if (params != null && !params.isEmpty()) {
for (Map.Entry&String, String& entry : params.entrySet()) {
stringBuffer
.append(entry.getKey())
.append(&=&)
.append(URLEncoder.encode(entry.getValue(), encode))
.append(&&&);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 删掉最后一个 & 字符
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
System.out.println(&--&&& + stringBuffer.toString());
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
httpURLConnection.setConnectTimeout(3000);
httpURLConnection.setDoInput(true);// 从服务器获取数据
httpURLConnection.setDoOutput(true);// 向服务器写入数据
// 获得上传信息的字节大小及长度
byte[] mydata = stringBuffer.toString().getBytes();
// 设置请求体的类型
httpURLConnection.setRequestProperty(&Content-Type&,
&application/x-www-form-urlencoded&);
httpURLConnection.setRequestProperty(&Content-Lenth&,
String.valueOf(mydata.length));
// 获得输出流,向服务器输出数据
OutputStream outputStream = (OutputStream) httpURLConnection
.getOutputStream();
outputStream.write(mydata);
// 获得服务器响应的结果和状态码
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
// 获得输入流,从服务器端获得数据
InputStream inputStream = (InputStream) httpURLConnection
.getInputStream();
return (changeInputStream(inputStream, encode));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return &&;
* // 把从输入流InputStream按指定编码格式encode变成字符串String
public static String changeInputStream(InputStream inputStream,
String encode) {
// ByteArrayOutputStream 一般叫做内存流
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] data = new byte[1024];
int len = 0;
String result = &&;
if (inputStream != null) {
while ((len = inputStream.read(data)) != -1) {
byteArrayOutputStream.write(data, 0, len);
result = new String(byteArrayOutputStream.toByteArray(), encode);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Map&String, String& params = new HashMap&String, String&();
params.put(&username&, &admin&);
params.put(&password&, &123&);
String result = sendPostMessage(params, &utf-8&);
System.out.println(&-result-&&& + result);
服务器端: LoginAction.java
package com.login.
import java.io.IOE
import java.io.PrintW
import javax.servlet.ServletE
import javax.servlet.http.HttpS
import javax.servlet.http.HttpServletR
import javax.servlet.http.HttpServletR
public class LoginAction extends HttpServlet {
* Constructor of the object.
public LoginAction() {
* Destruction of the servlet. &br&
public void destroy() {
super.destroy(); // Just puts &destroy& string in log
// Put your code here
* The doGet method of the servlet. &br&
* This method is called when a form has its tag value method equals to get.
* @param request
the request send by the client to the server
* @param response
the response send by the server to the client
* @throws ServletException
if an error occurred
* @throws IOException
if an error occurred
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
* The doPost method of the servlet. &br&
* This method is called when a form has its tag value method equals to
* @param request
the request send by the client to the server
* @param response
the response send by the server to the client
* @throws ServletException
if an error occurred
* @throws IOException
if an error occurred
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(&text/charset=utf-8&);
request.setCharacterEncoding(&utf-8&);
response.setCharacterEncoding(&utf-8&);
//客户端 HttpUtils并没有写request方法是post ,但服务器端可自动识别
String method = request.getMethod();
System.out.println(&request method :&+method);
PrintWriter out = response.getWriter();
String username = request.getParameter(&username&);
System.out.println(&-username-&&&+username);
String password = request.getParameter(&password&);
System.out.println(&-password-&&&+password);
if (username.equals(&admin&) && password.equals(&123&)) {
// 表示服务器段返回的结果
out.print(&login is success !&);
out.print(&login is fail !&);
out.flush();
out.close();
* Initialization of the servlet. &br&
* @throws ServletException
if an error occurs
public void init() throws ServletException {
// Put your code here
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致ASP模拟POST请求异步提交数据的方法
投稿:junjie
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了ASP模拟POST请求异步提交数据的方法,本文使用MSXML2.SERVERXMLHTTP.3.0实现POST请求,需要的朋友可以参考下
有时需要获取远程网站的某些信息,而服务器又限制了GET方式,只能通过POST数据提交,这个时候我们可以通过asp来实现模拟提交post数据,网上有挺多这样的例子的。下面的是我自己写的比较简洁易懂的函数。
首先,需要一个编码设置的函数,因为asp一般为gbk的,而标准的网站现在大都使用utf-8的。所以需要转换。
function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End function
其次就是用组件实现post数据的提交了,我这里使用了MSXML2.SERVERXMLHTTP.3.0。当然也可以使用其他的。
function PostHTTPPage(url,data)
set Http=server.createobject("MSXML2.SERVERXMLHTTP.3.0")
Http.open "POST",url,false
Http.setRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded"
Http.send(data)
if Http.readystate&&4 then
exit function
PostHTTPPage=bytesToBSTR(Http.responseBody,"utf-8")
set http=nothing
if err.number&&0 then err.Clear
End function
使用的时候就是这样子:
PostHTTPPage("www.jb51.net","str1=a&str2=b&str3=c")
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 数据库请求超时时间 的文章

 

随机推荐