`
eyesmore
  • 浏览: 364770 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

可怕的笑脸(关于正则表达式)

阅读更多

public static LoginAuthResponse parseAuthResult(String authResult) throws LoginAuthException {
        LoginAuthResponse resMsg = new LoginAuthResponse();
        String[] responseItems = authResult.split("[/^][$][/^]" );//分割符^&^要撇开Perl正则语法集保留字(可怕的笑脸)

        if (responseItems == null || responseItems.length < 2) {//不严格用等于2,以免服务端返回而外的说明信息
            throw new LoginAuthException("loginAuth登陆认证响应报文格式错误,报文:"+authResult);
        }
        resMsg.setRetcode(responseItems[0].toLowerCase());//不区分大小写
        resMsg.setRetmsg(responseItems[1]);
        for(int i =0;i<responseItems.length;i++) {
            resMsg.getAdditionalInfo().put("F"+i, responseItems[i]);
        }
        return resMsg;
    }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics