你是否正在寻找关于setrequestproperty的内容?让我把最吸引人的东西奉献给你:
1、 cmnet
private HttpConnection connectNet(HttpConnection conn) throws Exception {
conn = (HttpConnection) Connector.open("http://" + serverName + "http://blog.csdn.net/" + url);
conn.setRequestMethod(HttpConnection.POST);
//Set the request method and headers
conn.setrequestproperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
conn.setrequestproperty("Content-Language", "en-US");
// conn.setrequestproperty("Connection", "close");
conn.setrequestproperty("Connection", "Keep-Alive");
// conn.setrequestproperty("Pragma", "no-cache");
conn.setrequestproperty("Content-Type", "application/xml");
return conn;
}
2 、cmwap (设置 String headerField = conn.getHeaderField("Content-Type");
debug("headerField:" + headerField);
if (!headerField.startsWith("application/xml")) repeat连接即可把移动的连接提示去掉 application/xml为自己在servlet设置 如果你不是用的application/xml 则设置成你用的类型即可)
private HttpConnection connectWap(HttpConnection conn) throws Exception {
conn = (HttpConnection) Connector.open("http://10.0.0.172:80/" + url, Connector.READ_WRITE, true);
conn.setrequestproperty("X-Online-Host", serverName);
conn.setrequestproperty("Accept", "/");
conn.setRequestMethod(HttpConnection.POST);
//Set the request method and headers
conn.setrequestproperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
conn.setrequestproperty("Content-Language", "en-US");
conn.setrequestproperty("Connection", "Keep-Alive");
conn.setrequestproperty("Content-Type", "application/xml");
return conn;
}