All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.khthink.easyapi.factory.request.FormRequest Maven / Gradle / Ivy

The newest version!
package cn.khthink.easyapi.factory.request;

import cn.khthink.easyapi.action.RequestData;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 表单请求数据转换
 *
 * @author kh
 */
public class FormRequest implements RequestData {
    @Override
    public JSONObject getDatas(HttpServletRequest request) {
        JSONObject jsonObject = new JSONObject();
        Map map = request.getParameterMap();
        for (Map.Entry entry : map.entrySet()) {
            if (entry.getValue().length == 1) {
                jsonObject.put(entry.getKey(), entry.getValue()[0]);
            } else {
                jsonObject.put(entry.getKey(), entry.getValue());
            }
        }
        return jsonObject;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy