I; versuche, in der DB als BLOB in GSP gespeichert um ein Bild anzuzeigen, aber es zeigt nicht, hier ist mein Code:ein Bild in der APS-Anzeige
Domain:
class Photos {
Date dateCreated
byte [] photo
Date lastUpdated
}
static mapping ={ photo(sqlType:"BLOB") }
}
Controller:
def display()
{
def photosInstance = Photos.get(1).photo
byte [] image =params.photos // byte array
response.setHeader('Content-length', "${image.length}"
response.contentType = 'image/jpeg' // or the appropriate image content type
response.outputStream << image
response.outputStream.flush()
}
GSP:
<g:each var="img" in="${photosInstance}">
<img src="${createLink(action: 'display', params:[photos:"${img}"])}">
</g:each>
ist dies der Link:
http://localhost:8080/myApp/ads/display?photos=%5B65%2C+110%2C+100%2C+114%2C+111%2C+105%2C+100%2C+49%2C+46%2C+106%2C+112%2C+103%5D
hier ist der Ansicht:
irgendwelche Hinweise?
photosInstance.photos sollte photosInstance.photo sein, und es gibt keine listts in dieser Klasse, so dass keine Schleife ist notwendig – billjamesdev
nichts half, andere Vorschläge? – Sherif