Browse Source

登陆username为空时的npe问题

master
vito 9 years ago
parent
commit
0655c626ba
  1. 31
      designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java

31
designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java

@ -279,23 +279,26 @@ public class BBSLoginDialog extends UIDialog {
* @return 同上 * @return 同上
*/ */
public static boolean login(String username, String password) { public static boolean login(String username, String password) {
try { if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK);
} catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error(e.getMessage());
}
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.login") + "&username=" + username + "&password=" + password;
HttpClient client = new HttpClient(url);
client.setTimeout(TIME_OUT);
if (client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK) {
try { try {
String res = client.getResponseText(EncodeConstants.ENCODING_GBK); username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK);
if (res.contains(LOGIN_SUCCESS_FLAG)) { password = URLEncoder.encode(password, EncodeConstants.ENCODING_GBK);
return true; } catch (UnsupportedEncodingException e) {
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.login") + "&username=" + username + "&password=" + password;
HttpClient client = new HttpClient(url);
client.setTimeout(TIME_OUT);
if (client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK) {
try {
String res = client.getResponseText(EncodeConstants.ENCODING_GBK);
if (res.contains(LOGIN_SUCCESS_FLAG)) {
return true;
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
} }
return false; return false;
} }

Loading…
Cancel
Save