domain中用byte类型
自动生成的页面就可以上传图像文件至数据库
写个闭包来输出图像的数据流
def showImage = {
response.setContentType("image/png");
OutputStream out = response.getOutputStream();
if(params.id){
def custom = Custom.findByCusId(params.id )
if(custom.cusImage==null){
println('custom 没有图片')
java.io.File file = new File(servletContext.getRealPath( "/images") +"/null.jpg")
byte[] bytes= file.readBytes()
out.write(bytes)
out.close();
} else {
def image= custom.cusImage
//println image
byte[] bytes= image
out.write(bytes)
//javax.imageio.ImageIO.write(bytes, "PNG", out);
out.close();
}
}else{
java.io.File file = new File(servletContext.getRealPath( "/images") +"/null.jpg")
byte[] bytes= file.readBytes()
out.write(bytes)
out.close();
println 'custom 没有传ID'
}
}
页面上这样调用就可以看到了
<image src="${createLink(controller:"custom", action:"showImage",id:custom.cusId)}" height="150" width="150"/>
更多信息请点击文章来源:http://www.haohaonews.com/show.php?tid=17
分享到:
相关推荐
The Grails Framework - Reference Documentation
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part2 共两个包,解压后需要将扩展名.zip.bak改名为.zip重新解压。 http://dist.springsource.com/release/STS/3.8.1.RELEASE/dist/ e4.6/spring-tool-...
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part1 共两个压缩包,解压后将扩展名.zip.bak改为.zip再次解压。
grails-1.0 中文参考文档 网上收集而来,对 e 文不太熟悉的朋友可以参考一下,有些翻译的不好理解,最好对照着官方的e 文的参考文档
grails参考文档 The Grails Framework - Reference Documentation Authors: Graeme Rocher, Marc Palmer Version: 1.0.3
Grails的权限管理的spring插件0.5版本
漏洞修补好象是传asp等后缀名的时候,生成的是nba的后缀。上传原来很简单在后缀加个空格就可以了
Grails-2.4.4-用户手册
grails 中文文档+grails-fckeditor-0.9.5.zip插件
grails-docs-2.0.0
grails3.2.8 part1
prestige.zip,android的mvc模式,android的代码生成驱动的mvc模式。
Grails Web 应用框架:grails-core
grails-quartz-0.4.1 插件,直接安装
grails-3.0.5-ga (2/2), for somebody who can not download
grails-doc-1.0-beta1-中文.rar。Grails 1.0 学习资料。
grails-docs-1.0,api文档。html格式
Spring Websocket Grails插件 该插件旨在使Spring 4.0中引入的websocket支持可用于Grails应用程序。 您也可以使用相应的Spring docs / apis / samples作为参考。 在本自述文件中多次提到了这一点,因为其中详细...
grails-reference-documentation-1.1.x.pdf