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;
}
可怕的笑脸(关于正则表达式)
最新推荐文章于 2025-11-25 08:44:41 发布
本文介绍了一个用于解析登录认证响应的方法,该方法通过分析接收到的字符串格式认证结果,并将其转换为LoginAuthResponse对象,以便进一步处理。文章展示了如何检查响应的有效性、提取返回码和消息等关键信息。
114

被折叠的 条评论
为什么被折叠?



