在上传的时候,我参考了微信图文内容的做法写了一个上传的,但是在使用的是我用了一个字段叫img,提交后台,一直 获取不到val;而且调用
bbCarouselImgService.insert(bb_carousel_img);
会使用到下面的字段,但是我的字段只有,id,img,addtime,怎么解
INSERT INTO bb_carousel_img(id,img,addtime,opBy,opAt,delFlag) VALUES(3,'NULL','2019-03-08 11:00:58','462ea26b099841ea95c074fa2b9cf1f5',1552014059,false) "
图片
<%if(!isEmpty(obj.img)){%>
<%}%>
<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
</div>
</div>
</div>
</form>、
我是这么写的,但是一直获取不到
<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
action="${base}/platform/use/banner/addDo" method="post">
<div class="row mb10">
<div class="col-lg-12">
<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="true">
</div>
<div id="puimg" style="padding: 5px;">
<%if(!isEmpty(obj.img)){%>
<img src='${obj.img!}' style='width:60%;height:60%;'>
<%}%>
</div>
<input type="hidden" id="img" name="img" value="${obj.img!}" >
</div>
</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>
'uploadScript': '${base}/open/file/upload/image',
'onUploadComplete': function (file, data) {
data = JSON.parse(data);
if (data.code == 0) {
Toast.success(data.msg);
$("#puimg").html("<img src='" + data.data + "' style='width:200px;height:200px;'>");
$("#img").val('http://${AppDomain}${base}'+data.data);
} else {
clearFile();
Toast.error(data.msg);
}
},
js也有赋值的,
是实体
是实体
@Table("bb_carousel_img")
public class Bb_carousel_img extends Model implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Id
@Prev({
@SQL(db = DB.ORACLE, value="SELECT BB_CAROUSEL_IMG_S.nextval FROM dual"),
@SQL(db = DB.OTHER, value="SELECT MAX(id) FROM bb_carousel_img")
})
private Integer id;
@Column
private String img;
@Column
private String addtime;
从页面提交图片开始
<div class="content-wrap">
<div class="wrapper" style="min-height:500px;">
<section class="panel panel-form">
<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
action="${base}/platform/use/banner/addDo" method="post">
<div class="row mb10">
<div class="col-lg-12">
<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="true">
</div>
<div id="puimg" style="padding: 5px;">
<%if(!isEmpty(obj.img)){%>
<img src='${obj.img!}' style='width:60%;height:60%;'>
<%}%>
</div>
<input type="hidden" id="img" name="img" value="${obj.img!}" >
</div>
</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>
</section>
</div>
</div>
<script language="JavaScript">
function clearFile() {
$("#puimg").html("");
$("#queue").html("");
$("#img").val("");
}
$(document).ready(function () {
$('#file_upload').uploadifive({
'auto': true,
'multi': true,
'width': '100%',
'height': '30',
'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);
$("#puimg").html("<img src='" + data.data + "' style='width:200px;height:200px;'>");
$("#img").val('http://${AppDomain}${base}'+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) {
form.find("button:submit").button("loading");
},
success: function (data, statusText, xhr, form) {
if (data.code == 0) {
Toast.success(data.msg);
clearFile();
form.resetForm();
} else {
Toast.error(data.msg);
}
form.find("button:submit").button("reset");
}
});
});
</script>
然后到控制层
@At
@Ok("json")
@RequiresPermissions("hy.use.banner.add")
@SLog(tag = "添加轮播图", msg = "图片")
public Object addDo(@Param("..") Bb_carousel_img bb_carousel_img, HttpServletRequest req) {
try {
bb_carousel_img.setAddtime(DateFormatUtil.YY_MM_DD_HH_mm_ss());
//bbCarouselImgService.
bbCarouselImgService.insert(bb_carousel_img);
return Result.success("system.success");
} catch (Exception e) {
return Result.error("system.error");
}
}
然后我到这里就获取不到图片,并且我的实体没有的字段都出来了
@Table("bb_carousel_img")
public class Bb_carousel_img extends Model implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Id
@Prev({
@SQL(db = DB.ORACLE, value="SELECT BB_CAROUSEL_IMG_S.nextval FROM dual")
//@SQL(db = DB.OTHER, value="SELECT MAX(id) FROM bb_carousel_img")
})
private Integer id;
@Column
private String img;
@Column
private String addtime;
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id=id;
}
public String getImg()
{
return img;
}
public void setImg(String img)
{
this.img=img;
}
public String getAddtime()
{
return addtime;
}
public void setAddtime(String addtime)
{
this.addtime=addtime;
}
}
最后运行就是拿不到图片,在插入的时候就报错了,多了几个字段,但是我数据库表没有,实体也没有,这个是不行加载数据表的吗?
[DEBUG] 2019-03-08 14:39:33,243 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.uid()
[DEBUG] 2019-03-08 14:39:33,250 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=RUN
[DEBUG] 2019-03-08 14:39:33,308 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.now()
[DEBUG] 2019-03-08 14:39:33,313 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=RUN
[DEBUG] 2019-03-08 14:39:33,319 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.flag()
[DEBUG] 2019-03-08 14:39:33,324 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=RUN
[DEBUG] 2019-03-08 14:39:33,347 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - INSERT INTO bb_carousel_img(img,addtime,opBy,opAt,delFlag) VALUES(?,?,?,?,?)
| 1 | 2 | 3 | 4 | 5 |
|------|---------------------|----------------------------------|------------|-------|
| NULL | 2019-03-08 14:39:32 | 462ea26b099841ea95c074fa2b9cf1f5 | 1552027173 | false |
For example:> "INSERT INTO bb_carousel_img(img,addtime,opBy,opAt,delFlag) VALUES('NULL','2019-03-08 14:39:32','462ea26b099841ea95c074fa2b9cf1f5',1552027173,false) "
[DEBUG] 2019-03-08 14:39:33,595 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'opBy' in 'field list'
有获取到就是这个,点击提交后就获取不到
<input type="hidden" id="img" name="img" value="http://47.106.185.98:8080/bbnutzwk/bbnutzwk/upload/image/20190308/oieab5jd3ujuppl0rukbrohjht.png_60x60q90.jpg">
但是我获取img,不是应该在只是获取这个value的,
<input type="hidden" id="img" name="img" value="${obj.img!}" >
请求的地址应该是这个
<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
action="${base}/platform/use/banner/addDo" method="post">
我提交表单的时候,应该能获取到img的value的啊。
而且我实体都没有opBy,opAt,delFlag这个,在插入的时候,就在插入的sql了是什么情况