cn.khthink.easyapi.factory.request.FormRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of EasyApi Show documentation
Show all versions of EasyApi Show documentation
A RESTFUL Framework for JavaWeb
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;
}
}