从不同的URL但相同的域加载jsp中的图像? [英] Load image in jsp from different URL but same domain?

查看:217
本文介绍了从不同的URL但相同的域加载jsp中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图像加载到位于类路径上 files 文件夹中的jsp中。





我尝试加载图片的.jsp的网址是。


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

解决方案

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.

这篇关于从不同的URL但相同的域加载jsp中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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