獲取MAP中所以參數

/**
     * Description: 獲取所有的傳遞參數
     *
     * @param 
     * @return Map<String,Object>
     * @throws 
     * @Author dongzhongwei
     * Create Date: 2015-2-9 下午3:12:24
     */
    public Map<String, String> getRequestParam() {
        HttpServletRequest request = MyRequestContextHolder.getCurrentRequest();
        try {
            request.setCharacterEncoding("UTF-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Map<String, String> result = new HashMap<String, String>();
        Iterator<?> iter = request.getParameterMap().entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            String key = entry.getKey().toString();
            String value = request.getParameter(key);
            try {
                value = new String(value.getBytes("iso8859-1"),request.getCharacterEncoding());
            } catch (UnsupportedEncodingException e) {
            }
            result.put(key, value);
        }
        return result;
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章