1. 存在1个Domain class Profile,其中有个字段是存放相片的
class Profile {
//Profile is owned by User
//unidirectional relationship, profile can load user
static belongsTo = User
//binary data in byte[]
byte[] photo
static mapping = {
columns {
photo type:'blob'
}
}
默认情况下,byte[]数组在mysql下建立的字段是tinyblob,当上传大点的图片时,就会出现问题
解决办法:运行程序后,手动将数据库的tinyblob
改成 longblob
,然后 然后,在datasouce.groovy中,把create-drop改成update,就可以了
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
//url = "jdbc:hsqldb:mem:devDB"
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "dens"
url = "jdbc:mysql://localhost:3306/hubbub?useUnicode=true&characterEncoding=utf8"
}
}