【发布时间】:2015-05-23 06:11:57
【问题描述】:
我正在使用 Grails 2.4.2。我将图像保存到 web-app 文件夹下名为 gameImage 的目录中。它在开发模式下完美运行。但是当我在 xampp 服务器中的 localhost 上运行战争时,视图中的图像没有显示,而是保存在目录中。以下是我的尝试::
在我的配置文件中>>>
gameImage.location = "web-app/apps/gameImage/"
在我的控制器中保存图像>>>
String fileName = grailsApplication.config.gameImage.location.toString() + distGameInstance.packageName + '_' + newGameImage.getOriginalFilename()
new File( grailsApplication.config.gameImage.location.toString() ).mkdirs()
newGameImage.transferTo( new File( fileName) )
在我想显示图像的地方>>>
<g:each in="${distributedGameListInstance}" status="i" var="androidDistGameInstance">
<div class="col-lg-3 col-md-4 col-xs-6 thumb" >
<a class="thumbnail" href="#">
<g:img uri="${resource(dir: "apps/gameImage", file: "${androidDistGameInstance.imageName}")}" style="height: 120px;width: 120px;" />
</a>
</div>
</g:each>
【问题讨论】:
-
并且您已将应用程序文件夹添加到规则中 grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', ' /plugins/*']
-
@vahid 感谢您的回复,但不明白。你能解释一下吗?
-
在配置文件中添加这一行但没有结果
-
它也包含您的应用程序文件夹? grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*', '/apps/*'] 也看看这里试试调试它stackoverflow.com/questions/18741877/…
标签: tomcat grails debian grails-2.0