开发新手,刚接触 望大家指点
代码段
new Thread() {
public void run() {
String httpURL = "http://115.159.118.230:8080/map/map";
URL url = null;
try {
url = new URL(httpURL);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
if (url != null) {
try {
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.connect();
DataOutputStream dos = new DataOutputStream(
conn.getOutputStream());
dos.writeInt(MyProtocal.LOGIN);
dos.writeInt(MyProtocal.ID_STUDENT);
dos.writeInt(Integer.parseInt(snoEditText.getText().toString()));
dos.writeUTF(pwdEditText.getText().toString());
dos.flush();
dos.close();
//程序到这就不运行了
DataInputStream dis = new DataInputStream(conn.getInputStream());
Log.i("tag", "dis");
int b= dis.readInt();
if(b==MyProtocal.OK){
Intent intent1 = new Intent(context, StudentMapActivity.class);
startActivity(intent1);
}
dis.close();
} catch (IOException e) {
e.printStackTrace();
}
} else {
Toast.makeText(context, "url is null",
Toast.LENGTH_SHORT).show();
}
}
}.start();
Logcat:
08-08 20:51:47.454: W/System.err(8915): java.io.FileNotFoundException: http://115.159.118.230:8080/map/map
08-08 20:51:47.454: W/System.err(8915): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177)
08-08 20:51:47.454: W/System.err(8915): at com.hfuu.map_ts.LoginActivity$3.run(LoginActivity.java:187)
tomcat配置文件web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app>
<servlet>
<servlet-name>mapServ</servlet-name>
<servlet-class>MapServerHttpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mapServ</servlet-name>
<url-pattern>/map</url-pattern>
</servlet-mapping>
</web-app>
登录时tomcat界面也没有打印出任何信息 没反应
希望大家帮忙!