接⼝返回html怎么打开页⾯,接⼝返回html页⾯展⽰在浏览器packagecn.sd.service.impl;importcn.sd.service.SpeedServiceI;importcn.sd.utils.OutKey;importcn.sd.utils.WxApi;importorg.jsoup.清风明⽉
* @description
* @date 2019/12/7 18:59*/@Servicepublic class SpeedServiceImpl implementsSpeedServiceI {private static final Logger logger = Logger(SpeedServiceImpl.class);/*** 某的appid*/
private String appId = "***********";/*** 约定的密钥*/
private String clearly = ">>#";
@Overridepublic voidshowHtmlPage(String openId, String phone, String card, HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
PrintWriter writer;try{
Writer();
}catch(IOException e) {
writer= newPrintWriter(System.out);
<("IO异常:", e);
}
Map UserInfo(appId, openId);
logger.info("关注⽤户信息:" +userInfo);
Map BindingMobileEntity(appId, openId);
logger.info("绑定⽤户信息:" +bindUserInfo);if (userInfo == null || bindUserInfo == null || userInfo.isEmpty()
||bindUserInfo.isEmpty()) {
logger.info("请关注【某】并绑定⼿机号后访问");
writer.println("请关注【某】并绑定⼿机号后访问");
}else{//1 关注
String subscribe = String.("subscribe"));//Y 绑定
String bindStatus = (String) ("bindingStatus");
logger.info("bindStatus:" + bindStatus + " && subscribe:" +subscribe);if ("Y".equals(bindStatus) && "1".equals(subscribe))
{//⼿机号码加密
String nbr =pt(phone, clearly);//中⽂加密
String area =pt(card, clearly);
String speedUrl= "***.**.***.**:****/***?nbr={nbr}&area={area}&clearly={clearly}";
Map map = new HashMap<>(4);
map.put("nbr", nbr);
map.put("area", area);
map.put("clearly", clearly);
html如何下载
logger.info("map:{}", map);
RestTemplate restTemplate= newRestTemplate();
String html= ForObject(speedUrl, String.class, map); Document document=Jsoup.parse(html);
logger.info("document:{}", document);
writer.println(document.outerHtml());
}else{
logger.info("请绑定⼿机号后访问");
writer.println("请绑定⼿机号后访问");
}
}
writer.close();
}
}

发表评论