Load image in jsp from different URL but same domain?

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:29:09

问题


I am trying to load an image into my jsp located in the 'files' folder on the class path.

The URL of the .jsp in which I try to load images is http://www.my-webapp.com/authenticated/dashboard. The problem is that jsp is searching for the 'files' folder inside the 'authenticated' folder instead of class path.

This is the URL I get when I use the 'Inspect Element' of Google Chrome:

How can I tell my jsp to search for 'files folder on classpath but not in 'authenticated' folder?

My struts.xml (if needed):

<package name="account" namespace="/authenticated" extends="struts-default">

    <action name="dashboard" class="DashLoader" method="execute">
        <result name="success">/authenticated/dashboard.jsp</result>
    </action>

</package>

Thank you


回答1:


The default content loader allows you to serve static content from the classpath. This loader handles URLs that start with /static. So, if you put your image on the classpath under the files package, then it could be accessed like /static/files/image.jpg.

You can read more about static content loader and configuration settings in the docs for Static Content.



来源:https://stackoverflow.com/questions/26174776/load-image-in-jsp-from-different-url-but-same-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!