【问题标题】:Unable to load images in the freemarker template无法在 freemarker 模板中加载图像
【发布时间】:2013-01-09 03:42:34
【问题描述】:

我对使用 Dropwizard 和 Freemarker 模板非常陌生。我正在尝试加载免费的标记模板。但是图像没有加载到正在显示的页面中

我使用html的标准img标签来显示图片

<img src="/media/images/mload.png" width="18" height="18" />

图像在 jar 文件中可用。

这是项目的结构

源代码 | - 主要的 | - 资源 | - 媒体 | - -图片 | ---mload.png

如果缺少任何显示图片的内容,请告诉我

【问题讨论】:

    标签: freemarker dropwizard


    【解决方案1】:

    来自the official documentation

    AssetBundle 提供了一种简单的方法,可以将服务的 src/main/resources/assets 目录中的静态资产作为可从服务中的 /assets/* 获得的文件。

    您需要将AssetBundle 添加到您的服务中,例如:

    @Override
    public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
        bootstrap.setName("hello-world");
        bootstrap.addBundle(new AssetsBundle());
    }
    

    【讨论】:

    猜你喜欢
    • 2012-03-29
    • 2013-03-18
    • 2018-07-04
    • 2012-09-07
    • 2017-08-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    • 2013-01-23
    相关资源
    最近更新 更多