//我的JS及html代码
<script type="text/javascript">
$(document).ready(function() {
initFileInput();
});
$(function() {
$("#pagination").pagination({
currentPage : 4,
totalPage : 16,
isShow : true,
count : 7,
homePageText : "首页",
endPageText : "尾页",
prevPageText : "上一页",
nextPageText : "下一页",
callback : function(current) {
$("#current").text(current);
}
});
});
$('#addtool').click(function() {
if ($("#tool-add-box").css('display') == 'none') {
$("#tool-add-box").css("display", "block");
} else {
$("#tool-add-box").css("display", "none");
}
});
closebox = function(a) {
var obj = document.getElementById(a);
if (obj.style.display == "block") {
obj.style.display = "none";
}
};
openbox = function(a) {
var obj = document.getElementById(a);
if (obj.style.display == "none") {
obj.style.display = "block";
}
};
function initFileInput() {
var projectfileoptions = {
language : 'zh',
type: 'POST',
dropZoneEnabled : false,
uploadUrl : url
};
$("#file").fileinput(projectfileoptions);
}
//后台代码(后台如何接受文件,我用MultipartFile file接受就会报错,
//用@PathVariable("file") MultipartFile file 也报错,只有不传文件参数才正常
//是不是我前台少了什么步骤或者我接受文件的方式不对?)
@RequestMapping(value = "/{param}", method = RequestMethod.POST)
@ResponseBody
public String uploadRecord(HttpServletRequest request,MultipartFile file) throws IOException {
System.out.println("上传!");
return "success";
}
form 加个属性看看 enctype="multipart/form-data"
另外一些表单的其他参数可以通过如下设置:
uploadExtraData : function(){
return {“a”:0, "b":1, “c”: $("#xx").val()};
}
你尝试下后台看看能不能获取a和b的值