Grails:获取控制器内的资产本地存储路径 [英] Grails : getting assets local storage path inside the controller

查看:112
本文介绍了Grails:获取控制器内的资产本地存储路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提取assets文件夹的物理路径才能从我的控制器写入文件。

I need to extract the assets folder physical path in order to write a file from my controller.

从控制器获取文件持久性的简短方法是什么?

Any short way of achieving the file persistency from the controller?

推荐答案

完整示例:

Complete example:

class ExampleService {
  def assetResourceLocator

  def someMethod() {
    Resource res = assetResourceLocator.findAssetForURI('test.css')
    String url = res.getURL()
    String uri = res.getURI()
  }
}

来源: https://stackoverflow.com/a/39642278/717267

这篇关于Grails:获取控制器内的资产本地存储路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆