诺基亚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上,中文成乱码了就是那个爸爸在网页上成了乱码。。!帮帮忙。
...全文
72 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinjiayy 2008-08-21
  • 打赏
  • 举报
回复
在客户端最好是改成url编码格式的
那中%+十六进制的那种
bianmazi 2008-08-01
  • 打赏
  • 举报
回复
貌似只支持UFT8格式吧.试试改成UFT8

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧