/** * @author liuh * @date 2019年6月13日 下午5:57:13 * @note 删除Druid 广告代码 */ public class RemoveDruidAdHandle extends Handler { private String visitPath = "/druid/js/common.js"; @Override public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) { // TODO Auto-generated method stub if (target.equals(visitPath)) { isHandled[0] = true; try { String text = Utils.readFromResource("support/http/resources/js/common.js"); text = text.replaceAll("<a.*?banner\"></a><br/>", ""); text = text.replaceAll("powered.*?shrek.wang</a>", ""); response.setContentType("text/javascript;charset=utf-8"); response.getWriter().write(text); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { next.handle(target, request, response, isHandled); } } }
广告代码在common.js中,替换js代码中广告链接,打完收工