I am a new J2ME, just start learning, Chinese garbled when trying to communicate with the HTTP site. I saw some heroes on the BBS, the simplest and efficient way is to communicate with JSP Writeutf, ReadUTF. But since I want to link the destination site is C #, I want to use the minimum change. Solution! Set the encoding in web.config in the C # project to UTF-8 (default is UTF-8). The following is the source code of J2ME: Import javax.microedition.midlet. *; Import javax.microedition.lcdui. *; Import javax.microedition.io. *; Import java.io. *; Import java.lang.string ;; public class HTTPTEST EXTENDS MIDLET {
PRIVATE DISPLAY; public httptest () {display = display.getdisplay;}
protected void startApp () throws MIDletStateChangeException {try {String url = "http://192.168.0.25/lt133/webform1.aspx?phone=13800000000&msg1=c2"; HttpConnection hc = (HttpConnection) Connector.open (url); DataInputStream dis = New DataInputStream ()); byte [] mydata = new byte [100]; string content = "; dish (mydata, 0, mydata.length); content = new string (MyData," UTF -8 "); Form f = new form (" http test "); f.append (content); display.setcurrent (f);} catch (exception e) {system.out.println (e.tostring ()) NotifyDestroyed ();}}
protected void pauseapp () {}
Protected void destroyApp (Boolean Arg0) throws MidletStateChangeException {}} The code is very simple, and it is not shown and explained. I hope to help with me the same beginner. I also hope that old birds can care more about our newcomers !!!!