get请求参数长度是有限制,post请求生成EXCEL表格
get请求导出excel后,增加参数长度后,无法导出excel。那么我就尝试使用post的方式将参数传递过去。
直接上代码.
// js
function exportData(){
if(false==chbox()){
return;
}
var result = "";
var a = document.getElementsByTagName("input");
for (var i = 0; i < a.length; i++) {
if (a[i].type == "checkbox") {
if (a[i].checked == true) {
result += ":" + a[i].value;
}
}
}
if(result!=""){
postDownFile({
url: contextPath+"/**/**/Controller.do?method=exportData",
data: result,
method: 'post'
});
}
}
var postDownLFile = function (options) {
var config = $.extend(true, {method: 'post'}, options);
var $iframe = $('<iframe id="down-file-iframe" />');
var $form = $('<form target="down-file-iframe" method="' + config.method + '" />');
$form.attr('action', config.url);
$form.append('<input type="hidden" name="result" value="' + config.data + '" />');
$iframe.append($form);
$(document.body).append($iframe);
$form[0].submit();
$iframe.remove();
}
后端
public AF exportData(AMapping mapping, AForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
String result=request.getParameter("result");
String[] re =result.split(":");
.
.
.
参考
[1]: https://blog.csdn.net/qq_25931677/article/details/89347060?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_utm_term-0&spm=1001.2101.3001.4242