标签:
private String initUrl(String preurl,String taskurl) { if(JavaUtil.match(taskurl, "/[a-z]+$")!=null) taskurl = taskurl + "/"; String urlEx = taskurl.substring(0, taskurl.lastIndexOf("/") + 1); String urlHost = ""; try { urlHost = taskurl.substring(0, taskurl.indexOf("/",9)); urlHost = taskurl.substring(0,taskurl.indexOf("/", urlHost.length()+1)); } catch (Exception e) { urlHost = taskurl.substring(0, taskurl.length()); } if (!preurl.startsWith("http")) { if(preurl.startsWith("/")||preurl.startsWith("../")) preurl=urlHost+preurl.replaceAll("\\.\\.", ""); else preurl=urlEx+preurl.replaceFirst("\\.", ""); preurl = preurl.replaceAll("//", "/"); } return preurl; }
标签:
原文地址:http://www.cnblogs.com/learningJAVA/p/4262336.html