我能够在MySQL中将图像保存为blob类型,现在我想使用struts2 jquery小部件来显示它。我使用了edittype=的“图像”,但它没有起作用。它只显示一些字符串。关于我应该用哪种编辑,有什么建议吗?
以下是我的jquery网格:
<sjg:grid
id="testresulttable1"
caption="Test Result Summary"
dataType="json"
href="%{testtrsurl}"
pager="true"
gridModel="gridTRSModel"
rowList="10,15,20"
rowNum="15"
viewrecords="true"
viewsortcols="[true, 'horizontal', true]"
resizable="true"
multiselect="false"
loadonce="false"
>
<sjg:gridColumn
name="screenshot"
index="screenshot"
title="screenshot"
sortable="true"
edittype="image"
/>
</sjg:grid>提前谢谢你的帮助。
发布于 2014-02-07 20:12:03
我接受了由四元数和黑马提供的答案,并实现了它们(感谢您的投入)。我还得到了另一个博客的帮助。
解决方案是: a.而不是blob,我使用varchar并将图像b的文件路径存储在我的网格中。我使用了格式化程序,它指向javascript c。javascript调用的是一个返回自定义结果类型的操作,该操作将传递到调用javascript thru属性的网格。
以下是javascript:
function formatImage(cellvalue, options, row) {
if(!cellvalue){
return "n/a";
}else{
var action = "http://localhost:8181/MySel20Proj-1.0/imageAction.action?imageId=" + cellvalue;
return "<a href="+"'"+action+"'"+"title='' class='thickbox'><img src='" + action + "' width='30' height='30 align='middle' border='0'/></a>";
}
}有关struts操作/配置,请参考以下站点:http://www.mkyong.com/struts2/struts-2-dynamic-image-example/
https://stackoverflow.com/questions/21539511
复制相似问题