点击图片上传提交的时候把其他字段也为空了这是怎么回事,大神指教一下??????????
前台代码
<%
layout("/layouts/platform.html"){
%>
<script src="${base!}/assets/plugins/ueditor/ueditor.config.js"></script>
<script src="${base!}/assets/plugins/ueditor/ueditor.all.min.js"></script>
<header class="header navbar bg-white shadow">
<div class="btn-group tool-button">
<a class="btn btn-primary navbar-btn" href="${base}/platform/iff/article" id="goBack" data-pjax><i class="ti-angle-left"></i>返回</a>
</div>
</header>
<div class="content-wrap">
<div class="wrapper" style="min-height:500px;">
<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
action="${base}/platform/iff/article/addDo" method="post">
<div class="col-lg-12">
<div class="form-group">
<label for="title" class="col-sm-2 control-label">文章标题</label>
<div class="col-sm-8">
<input type="text" id="title" class="form-control" name="title" data-parsley-required="true"
placeholder="文章标题" value="" >
</div>
</div>
<div class="form-group">
<label for="authorId" class="col-sm-2 control-label">文章作者</label>
<div class="col-sm-8">
<input type="text" id="authorId" class="form-control" name="authorId"
placeholder="文章作者" value="${username!}" >
</div>
</div>
<div class="form-group">
<label for="info" class="col-sm-2 control-label">文章简介</label>
<div class="col-sm-8">
<textarea id="info" name="info" class="form-control" style="width:100%;height:80px;"></textarea>
</div>
</div>
<div class="form-group">
<label for="releaseDate" class="col-sm-2 control-label">发布时间</label>
<div class="col-sm-8 input-group date form_datetime " style="padding-left: 16px;padding-right: 16px;" data-date="1979-09-16T05:25:07Z" data-date-format="dd MM yyyy - HH:ii p" data-link-field="releaseDate">
<input type="text" size="16" readonly class="form-control" value="${@date.getDateTime()}" data-parsley-required="true">
<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
<input type="hidden" id="releaseDate" name="releaseDate" value="${@date.getDateTime()}" />
</div>
<div class="form-group">
<label for="disabled" class="col-sm-2 control-label">取消发布</label>
<div class="col-sm-8 switcha">
<div class="mr15">
<input type="checkbox" id="disabled" name="disabled" class="js-switch-blue" value="true" >
</div>
</div>
</div>
<div class="form-group">
<label for="picurl" class="col-sm-2 control-label">标题图</label>
<div class="col-sm-8">
<div id="queue"></div>
<div>
<input id="file_upload" name="file_upload" type="file" multiple="false">
</div>
<div id="img" style="padding: 5px;">
</div>
<input type="hidden" id="picurl" name="picurl" value="" >
</div>
</div>
<div class="form-group">
<label for="content" class="col-sm-2 control-label">文章内容</label>
<div class="col-sm-8">
<textarea id="content" name="content" style="width:100%;height:200px;"></textarea>
</div>
</div>
</div>
<div class="col-lg-3"></div>
<div class="col-lg-6">
<div class="form-group text-center">
<label></label>
<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交..." >提 交</button>
</div>
</div>
</div>
</form>
</div>
</div>
<script language="JavaScript">
function clearFile() {
$("#img").html("");
$("#queue").html("");
$("#picurl").val("");
}
var ue;
$(document).ready(function () {
setTimeout(function () {
ue= new baidu.editor.ui.Editor();
ue.render('content');
},500);
myForm.init();
$('.form_datetime').datetimepicker({
language: 'zh-CN',
format:'yyyy-mm-dd hh:ii:ss',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1
});
$('#file_upload').uploadifive({
'auto': true,
'multi': false,
'width': '100%',
'height': '35',
'buttonText': '请选择图片',
'fileType': 'image/jpg,image/jpeg,image/png',
'fileSizeLimit': 1024,
'queueSizeLimit': 1,
'formData': {},
'queueID': 'queue',
'uploadScript': '${base}/open/file/upload/image',
'onUploadComplete': function (file, data) {
data = JSON.parse(data);
if (data.code == 0) {
Toast.success(data.msg);
$("#img").html("<img src='" + data.data + "' style='width:150px;height:95px;'>");
$("#picurl").val(data.data);
} else {
clearFile();
Toast.error(data.msg);
}
},
'onDrop': function (file, fileDropCount) {
clearFile();
},
'onClearQueue': function (queue) {
clearFile();
},
'onCancel': function () {
clearFile();
}
});
$('#addForm').ajaxForm({
dataType: 'json',
beforeSubmit: function (arr, form, options) {
sublime.showLoadingbar($(".main-content"));
},
success: function (data, statusText, xhr, form) {
if (data.code == 0) {
Toast.success(data.msg);
} else {
Toast.error(data.msg);
}
sublime.closeLoadingbar($(".main-content"));
}
});
});
</script>
<%}%>
后台代码
@At("/addDo")
@Ok("json")
@RequiresPermissions("platform.iff.article.add")
@SLog(tag = "图文表", msg = "${args[0].id}")
public Object addDo(@Param("..")Iff_article iffArticle, HttpServletRequest req) {
try {
iffArticleService.insert(iffArticle);
return Result.success("system.success");
} catch (Exception e) {
return Result.error("system.error");
}
}