From 0655c626ba342d0b36c9685b23564d5bf69e88ad Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 6 Jul 2016 11:34:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86username=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84npe=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/bbs/BBSLoginDialog.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java index c56e6547f..2845ccece 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java @@ -279,23 +279,26 @@ public class BBSLoginDialog extends UIDialog { * @return 同上 */ public static boolean login(String username, String password) { - try { - 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) { + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { try { - String res = client.getResponseText(EncodeConstants.ENCODING_GBK); - if (res.contains(LOGIN_SUCCESS_FLAG)) { - return true; - } - } catch (Exception e) { + username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); + password = URLEncoder.encode(password, 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 { + 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; }