以下是一个登录界面的提交按钮操作,运行结果没有提示错误,但是运行结果什么都没有,是不是Android当中不可以用request和response?mButton2.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
String id = mEditText1.getText().toString();
String pwdFld = mEditText2.getText().toString();
if (mEditText1.getText().length() == 0 || mEditText2.getText().length() == 0) {
toast();
mEditText1.setText(" ");
mEditText2.setText(" ");
}
/* //发送用户输入的用户名和密码给服务器
Request req = new Request();
req.setAction("userLogin");
req.setAttribute("id", id);
req.setAttribute("pwdFld", pwdFld);
System.out.println(id+ pwdFld);
//获取响应
Response response = null;
try {
response = ClientUtil.sendTextRequest(req);
} catch (IOException e1) {
e1.printStackTrace();
}
if(response.getStatus() == ResponseStatus.OK)
{
//获取当前用户
String newuser = response.getData("user");
System.out.println(newuser);
if(newuser!= null){ //登录成功
ClientDataBuffer.currentUser =newuser;
//跳入下一个Activity
//new UIChat(); //打开聊天窗体
}else{ //登录失败
String str = (String)response.getData("msg");
toast1(str);
//JOptionPane.showMessageDialog(UILogin.this, str,"登录失败",JOptionPane.ERROR_MESSAGE);
//new UILogin();
}
}else{
//JOptionPane.showMessageDialog(UILogin.this,
//"服务器内部错误,请稍后再试!!!","登录失败",JOptionPane.ERROR_MESSAGE);
}*/
{
@Override
public void onClick(View v)
{
String id = mEditText1.getText().toString();
String pwdFld = mEditText2.getText().toString();
if (mEditText1.getText().length() == 0 || mEditText2.getText().length() == 0) {
toast();
mEditText1.setText(" ");
mEditText2.setText(" ");
}
/* //发送用户输入的用户名和密码给服务器
Request req = new Request();
req.setAction("userLogin");
req.setAttribute("id", id);
req.setAttribute("pwdFld", pwdFld);
System.out.println(id+ pwdFld);
//获取响应
Response response = null;
try {
response = ClientUtil.sendTextRequest(req);
} catch (IOException e1) {
e1.printStackTrace();
}
if(response.getStatus() == ResponseStatus.OK)
{
//获取当前用户
String newuser = response.getData("user");
System.out.println(newuser);
if(newuser!= null){ //登录成功
ClientDataBuffer.currentUser =newuser;
//跳入下一个Activity
//new UIChat(); //打开聊天窗体
}else{ //登录失败
String str = (String)response.getData("msg");
toast1(str);
//JOptionPane.showMessageDialog(UILogin.this, str,"登录失败",JOptionPane.ERROR_MESSAGE);
//new UILogin();
}
}else{
//JOptionPane.showMessageDialog(UILogin.this,
//"服务器内部错误,请稍后再试!!!","登录失败",JOptionPane.ERROR_MESSAGE);
}*/
解决方案 »
- Android webView 加载网页时,使用本地图片替换网页内的图片
- 安装小白SDK Manager打不开
- Android 语言开发一个手机游戏
- 怎么提高android canvas绘图的速度?
- android 日历控件
- 求android手机横屏解释
- android 分享功能中如何去除不必要的分享程序 如360助手这些等等
- AndroidManifest.xml注册activity活动问题,求救````
- Android文件读写问题
- 如何用eclipse的tomcat建立服务器与连接本机WiFi的手机进行服务器-客户端通信
- 关于android自定义控件动态添加的初始化问题
- android禁用通知栏怎么写
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
at Server.RequestProcessor.run(RequestProcessor.java:37)
at java.lang.Thread.run(Thread.java:662)
不过想请你帮我回答另一个帖子的问题:Socket空指针异常的问题