Jhipster v2.20.0:无法在生产模式下加载静态图片

时间:2016-05-25 22:39:04

标签: angularjs jhipster

我在生产模式下部署了 Jhipster (v2.20.0)应用程序。在angularjs代码中,我把:

img.src = assets/.../mypicture.png. 

本地图片 il 正确加载,但在生产模式下我有错误:

[ERROR] org.springframework.boot.context.web.ErrorPageFilter - Cannot forward to error page for request [/assets/images/elements/teethschame/47.png] 

as the response has already been committed. As a result, the response may have the wrong status code. 

If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

请问这个问题吗?

由于

2 个答案:

答案 0 :(得分:0)

在JHipster 2.x中,grunt / gulp构建过程缩小并向您的图像添加修订哈希码,以便浏览器可以永久缓存它们。

因此,如果您在assets/images/mypicture.png中有图片,则会在dist/assets/images/mypicture-a1b2cde.png中显示该图片。然后在prod配置文件中,StaticResourcesProductionFilter/dist添加到任何资产请求之前,但它不知道修订代码。

因此,在您的情况下,您的代码必须引用版本化的图像名称,或者您应该将图像排除在assets文件夹之外,以排除修改后的图像。

答案 1 :(得分:-2)

感谢您的回复,但问题是我必须在resourrces目录中创建一个名为:static,public或resource的目录,并将我的image目录放在其中以便在spring boot中为它们提供服务。这在春季网站上有说明:https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot