打印HttpServletRequest

/**
     * 
     * getRequestURL:(将HttpServletRequest转成URL参数字符串 ). <br/>
     *
     */
    public static String getRequestURL(HttpServletRequest request) {
        
        StringBuilder sb = new StringBuilder();
        boolean isFirst = true;
        @SuppressWarnings("unchecked")
        Enumeration<String> er = request.getParameterNames();
        while (er.hasMoreElements()) {
            String name = (String) er.nextElement();
            String value = request.getParameter(name);
            if (isFirst) {
                sb.append(name + "=" + value);
                isFirst = false;
            }
            else {
                if (value != null) {
                    sb.append("&" + name + "=" + value);
                }
                else {
                    sb.append("&" + name + "=");
                }
            }
        }
        return sb.toString();
    }


你可能感兴趣的:(打印HttpServletRequest)