简体   繁体   中英

Jhipster v2.20.0 : Static picture can't be loaded in production mode

I deployed a Jhipster (v2.20.0) application in production mode. In an angularjs code i put :

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

Locally this picture il loaded correctly, but in production mode I have the error :

[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

Can you help me please, this problem ?

Thanks

In JHipster 2.x, the grunt/gulp build process minifies and adds a revision hash code to your images so that they can be cached forever by browser.

So, if you have an image in assets/images/mypicture.png , it will be available in dist/assets/images/mypicture-a1b2cde.png . Then in prod profile, the StaticResourcesProductionFilter will prepend /dist to any request for an asset but it does not know about the revision code.

So, in your case either your code must refer to the versioned image name or you should exclude your images from being revisioned by moving them outside assets folder.

Thanks for your response, but the problem was that i had to create a directory named :static, public or resource, in resourrces directory, and put my image directory in it to serve them in spring boot. This was indicated in the spring site : https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM