你是否正在尋找關于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;
}