Android客户端http服务器连接出问题

家有小辉 2014-10-27 09:55:55

Android客户端主要代码
   findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new Thread(new Runnable(){
public void run() {
mHand.post(new Runnable() {
public void run() {
System.out.println(txt_Fuwiqi1.getText());
if(txt_Fuwiqi1.getText().toString().trim().equals("Dao")){
reder.rederNet("http://192.168.69.183:8080/myhttpGetPost/Dao?name="+txt_name1.getText(), txt1);
}else if(txt_Fuwiqi1.getText().toString().trim().equals("Re_Str")){
reder.rederNet("http://192.168.69.183:8080/myhttpGetPost/Re_Str?name="+txt_name1.getText(), txt1);
}else{
Toast toast=Toast.makeText(getApplicationContext(),"请添加服务器名字!!!",Toast.LENGTH_LONG );
toast.show();
}
}
});
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
e.printStackTrace();
Toast t=Toast.makeText(getApplicationContext(), "服务器无法响应!", Toast.LENGTH_LONG);
t.show();
}
}
}).start();
}
});
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
mHand.post(new Runnable() {
public void run() {
System.out.println(txt_Fuwiqi2.getText());
if(txt_Fuwiqi2.getText().toString().trim().equals("Dao")){
reder.rederNet("http://192.168.69.183:8080/myhttpGetPost/Dao?name="+txt_name2.getText(),txt2);
}else if(txt_Fuwiqi2.getText().toString().trim().equals("Re_Str")){
reder.rederNet("http://192.168.69.183:8080/myhttpGetPost/Re_Str?name="+txt_name2.getText(),txt2);
}else{
Toast toast=Toast.makeText(getApplicationContext(),"请添加服务器名字!!!",Toast.LENGTH_LONG );
toast.show();
}
}
});
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
e.printStackTrace();
Toast to=Toast.makeText(getApplicationContext(), "服务器无法响应!", Toast.LENGTH_LONG);
to.show();
}
}
}).start();

}
});


web服务器主要代码:

1.
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getOutputStream().println("This is result is Get"+" "+request.getParameter("name"));
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getOutputStream().println("This is result is post"+" "+request.getParameter("name"));
}
2.protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Re_String str=new Re_String();
String name=str.name(request.getParameter("name").toString())+"123";
response.getOutputStream().println(name);

}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Re_String str=new Re_String();
String name=str.name(request.getParameter("name").toString());
response.getOutputStream().println(name);

}

...全文
347 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Boris_liulang 2014-10-31
  • 打赏
  • 举报
回复
出什么问题了啊 贴出来错误日志之类的 或者描述下啊
开发者_android 2014-10-31
  • 打赏
  • 举报
回复
就是出错了,贴错误信息呀
家有小辉 2014-10-30
  • 打赏
  • 举报
回复
有木有人知道的啊
家有小辉 2014-10-28
  • 打赏
  • 举报
回复
引用 1 楼 svenwang 的回复:
出问题是啥问题?有日志吗?
他就是出错了,链接服务器的时候,他的错误是URL没有传进去
svenwang 2014-10-27
  • 打赏
  • 举报
回复
出问题是啥问题?有日志吗?

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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