私は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私の答えはあなたの質問には良いと思うなら、それを受け入れてください。 –