标签:imp cat 设置 pac inpu charset eth ext.get final
package test;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.servlet.http.HttpServlet;
public class MainTest extends HttpServlet{
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
//HttpServletRequest request = ServletActionContext.getRequest();
String locationUrl = "http://www.baidu.com";
URL url;
try {
url = new URL(locationUrl);
HttpURLConnection connection;
connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
//超时设置
connection.setReadTimeout(10000);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/html");
connection.setRequestProperty("Accept-Charset", "utf-8");
connection.setRequestProperty("contentType", "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
}
}
标签:imp cat 设置 pac inpu charset eth ext.get final
原文地址:http://www.cnblogs.com/hxinbk/p/6777637.html