诺基亚J2ME网络中文问题
fxy1 2008-08-01 11:47:27 解决了。弄了半天安错了。混淆后出现了两个包,我还以为要用新名称那个包,弄了半天还是要用原名称的包。现在还有一个问题,大家能不能再帮我想一想。现在我连接网络,客户端代码如下:HttpConnection hc = null;
OutputStream os = null;
String message = "";
java.lang.StringBuffer temp=new StringBuffer();
temp.append("mobileno="+ this.txtMobileNo .getString()
+"&password="+ txtPassword.getString());
temp.append("&contacts=");
for(int i=0;i <1;i++)
{
message = (String)itemList.elementAt(i);
temp.append(message+",");
try {
temp.append(new String("爸爸$15999941299,".getBytes("gb2312")));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String url=ServiceUrl+"?"+temp;
try {
hc = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
hc.setRequestMethod(HttpConnection.POST);
hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
os = hc.openOutputStream();
// DataOutputStream ks=new DataOutputStream(os);
hc.setRequestProperty("Content-Length", String.valueOf(temp.length()));
byte[] request_body = temp.toString().getBytes();
for (int j = 0; j < request_body.length; j++)
{
//ks.writeUTF(request_body[j]);
os.write(request_body[j]);
}
os.flush();
服务器代码如下: String mobileno=new String(request.getParameter( "mobileno" ).getBytes("8859_1"));
String password=new String(request.getParameter( "password" ).getBytes("8859_1"));
String contacts=new String(request.getParameter( "contacts" ).getBytes("8859_1"));
但在WTK模拟器上中文是正确的,安装到诺基亚N72上,中文成乱码了就是那个爸爸在网页上成了乱码。。!帮帮忙。