设置头参数

// 设置Content-Type头参数
        // postMethod.setRequestHeader(CONT_TYPE, strContType);
        Enumeration<String> enumeration = ServletActionContext.getRequest().getHeaderNames();
        // ServletActionContext.getRequest().getParameterNames()
        for (; enumeration.hasMoreElements();)
        {
            String name = enumeration.nextElement();
            if ("cookie".equals(name))
            {
            continue;
            }
            postMethod.setRequestHeader(name, ServletActionContext.getRequest().getHeader(name));
        }
       
        Enumeration<String> enumeration2 = ServletActionContext.getRequest().getParameterNames();
       
        List<NameValuePair> pariList = new ArrayList<NameValuePair>();
       
        for (; enumeration2.hasMoreElements();)
        {
            String name = enumeration2.nextElement();
            if ("address".equals(name))
            {
            continue;
            }
            NameValuePair nameVaPar = new NameValuePair();
            nameVaPar.setName(name);
            nameVaPar.setValue(ServletActionContext.getRequest().getParameter(name));
            pariList.add(nameVaPar);
        }
       
        postMethod.setRequestBody(pariList.toArray(new NameValuePair[pariList.size()]));

你可能感兴趣的:(参数)