我有一個名爲Product的域類。我已將這些信息和圖像保存在數據庫中。但在檢索信息時,我檢索了所有信息,但無法檢索圖像。從grails中檢索數據庫中的信息和圖像
Domain Class
class Product {
String productName
String description
int price
byte [] photo
String phototype
}
I have saved the information and image in database using this action in ProductController. In gsp page, I used <g:uploadForm> tag to get information.
def saveProduct(){
def pic = request.getFile('picture')
product.properties['productName','description','price'] = params
product.photo=pic.bytes
product.phototype=pic.contentType
if(!product.save()){
render (view: "/adminPanel", model: [upload: "Product Failed to Upload",product:product])
return
}
else {
render (view: "/adminPanel", model: [upload: "Product Successfully Saved!!",product: product])
}
}
這段代碼保存在數據庫中的信息和圖像。現在,我如何在adminPanel.gsp頁面中顯示圖像和產品信息?我應該在控制器和gsp頁面上寫什麼樣的代碼?
謝謝@http:/ /stackoverflow.com/users/1233197/mikelis-baltruks Sir – Sagar
@Sagar如果您認爲我的回答對您的問題有好處,請點擊右側的複選標記接受它。 –