首页 > 代码库 > initUrl方法

initUrl方法

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;    }

 

initUrl方法