写了一个很简单的login page,就是用post传值到服务器上,然后服务器验证后返回yes,no,然后程序根据返回值判断是否允许登录,可是关于返回值这里,我用TextView或者Toast显示的永远都是yes,可是用if(responseCode=="yes")这样判断永远是false,也就是说responseCode不等于"yes",这是什么原因呢?下面是代码:
post.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse response = new DefaultHttpClient().execute(post);
if(response.getStatusLine().getStatusCode()==200) {
responseCode = EntityUtils.toString(response.getEntity());
TextView tv = (TextView)findViewById(R.id.tv);
tv.setText(responseCode);
if(responseCode == "yes") 
     return true;
else
return false;
}
tv这里显示的就是yes,但是下面那个if语句永远进不了true那里,永远都是判成false,responseCode是String类型