后端接口:
@RequestMapping(value = "/export")
public void export(@RequestParam("obj") String obj, HttpServletResponse response) {
JSONObject jsonObject = JSONObject.parseObject(obj);
User user = (User) ServletUtils.getSession().getAttribute(CacheConst.RISK_USER);
List<String> baseIdList = null;
if (jsonObject.containsKey("search")){
RiskUnionResolve riskUnionResolve = JSON.toJavaObject(jsonObject.getJSONObject("search"),RiskUnionResolve.class);
baseIdList = riskResolveItemMapper.selectByRiskItemBaseIdList(riskUnionResolve, user.getCompanyId());
}
riskInquiryService.export(jsonObject, response, baseIdList);
System.out.println(obj);
}
前端
var url = prefix + "/export";
var form = $("<form></form>").attr("action", url).attr("method", "post");
form.append($("<input></input>").attr("type", "hidden").attr("name", "obj").attr("value", JSON.stringify(obj)));
form.appendTo('body').submit().remove();