HttpClient请求时使用jar包
package com.test;
import java.net.URLDecoder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
/**
* @title
* @descriptor
* @author zy
* @version 2013-8-26
*/
public class AppAddTest {
public static void main(String[] args) throws Exception {
int responseCode = 0;
try {
String url = "http://127.0.0.1:8080/test/LineToOnline.jsp";
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(url);
postMethod.setParameter("OAMessage", "410000000021");
responseCode = client.executeMethod(postMethod);
if (responseCode == 200) {
String callBackString = postMethod.getResponseBodyAsString();
System.out.println("请求返回结果为:" + URLDecoder.decode(callBackString));
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("网页代码" + responseCode);
}
}
<%@page import="java.net.URLDecoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
//String str=new String(request.getParameter("OAMessage").getBytes("ISO8859_1"),"UTF-8");
String str=request.getParameter("OAMessage");
str=URLDecoder.decode(str);
System.out.println(str);
%>
<!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=UTF-8">
<title></title>
</head>
<body>
</body>
</html>