首页 \ 问答 \ 如何从spring mvc中的resources / images文件夹中加载图像?(How can I load an image from my resources/images folder in spring mvc?)

如何从spring mvc中的resources / images文件夹中加载图像?(How can I load an image from my resources/images folder in spring mvc?)

我正在尝试从我的resources / images文件夹中加载2个图像并将它们显示在我的index.jsp上:

<img src="<c:url value='/resources/images/harry_potter.jpg'/>"/>
<img alt="Image" src="${pageContext.request.contextPath}/resources/images/harry_potter.jpg">

<img src="<c:url value='/resources/images/hp.jpg'/>"/>
<img alt="Image" src="${pageContext.request.contextPath}/resources/images/hp.jpg">

当我加载页面时,图像不会出现,而是有图像图标。 正如你在我的index.jsp中看到的那样,我尝试了两种不同的加载图像的方法

我有一个application.xml页面和一个dispatcher-servlet page.xml

在每个文件中,我都尝试将其放在上下文中:component-scan

<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />

但我仍然没有在索引页面上看到我的图像。 有谁知道为什么没有显示

我的文件结构供参考:
文件图像视图
文件图像视图

在我的web.xml中供参考:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

控制台供参考

控制台图像视图
控制台图像视图


I am trying to load 2 images from my resources/images folder and display them on my index.jsp:

<img src="<c:url value='/resources/images/harry_potter.jpg'/>"/>
<img alt="Image" src="${pageContext.request.contextPath}/resources/images/harry_potter.jpg">

<img src="<c:url value='/resources/images/hp.jpg'/>"/>
<img alt="Image" src="${pageContext.request.contextPath}/resources/images/hp.jpg">

When I load the page images don't appear, instead there are image icons. As you've seen in my index.jsp, I've tried 2 different methods for loading an image

I have an application.xml page and a dispatcher-servlet page.xml

In each file I have tried putting this under the context:component-scan

<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />

but I still do not see my images on the index page. Does anyone know why this isn't showing

My File Structure for reference:
File Image View
File Image View

In my web.xml for reference:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

Console for reference

Console Image View
Console Image View


原文:https://stackoverflow.com/questions/36928098
更新时间:2023-12-26 11:12

最满意答案

好的,我修好了。 我的特定版本的linux,thermal_sys框架要求我们为get_crit_temp声明一个函数。 如果您没有定义它,它将在取消注册设备时尝试删除此设备文件,并且最终会出现NULL引用错误。 请注意,这不适用于3.0以上的Linux版本


Ok I fixed it. My specific version of linux, the thermal_sys framework requires us to have a function declared for get_crit_temp. If you don't define this, it will try to remove this device file upon unregistering the device and it will end up with a NULL reference error. Note that this does not apply to linux versions above 3.0

相关问答

更多
  • 在较旧的Android版本中,您的Notification 必须具有内容Intent,因此当用户单击您的通知时,会发生某些事情。 这意味着您必须: 创建一个指向某处的Intent对象,例如MainActivity 。 确保添加Intent.FLAG_ACTIVITY_NEW_TASK标志。 Intent intent = new Intent (this, MainActivity.class); intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); 将其转换为 ...
  • 您必须创建一个临时blit缓冲区并使用它将内容复制到私有缓冲区。 这是示例代码: buffer = [self.device newBufferWithLength:sizeof( vertexes ) options:MTLResourceStorageModePrivate]; id blitBuffer = [self.device newBufferWithBytes:vertexes ...
  • 尝试使用MPMoviePlayerController而不是AVPlayer,对于简单的解决方案,MPMoviePlayerController有一个更简单的API。 使MPMoviePlayerController成为一个全局实例,使其可以通过整个应用程序访问,然后在需要时初始化它。 首先尝试在本地播放视频并检查它是否解决了问题 Try using the MPMoviePlayerController instead of the AVPlayer, for simple solutions, the ...
  • 在经过数小时的调查和试用后,我确认它是由第三方框架集成到应用程序引起的:即使该空应用程序与UIImagePickerController崩溃,如果我将该框架链接到那里。 感谢您的帮助! After hours of investigation and tryout, I am confirmed that it is caused by a third-party framework integrated to the app: even that empty app crashes with UIImag ...
  • 该错误清楚地表明您使用了错误的主题。 您使用的活动来自android.support包,这些活动需要一个ThemeCompat主题,而不是Theme.Material.Light ,它是android.app包中的活动。 像这样重写你的主题: 这个错误将会消失。 The error clearly states that yo ...
  • 如果单元格从tableview成功出列,则忽略将指针bottomLabel设置为任何特定值,然后隐式取消引用它。 如果你真的不希望它在单元格出列时指向任何东西,那么将它初始化为指向nil: UITextView *bottomLabel = nil; 在Objective-C中向nil发送消息总是安全的。 你已经注释掉了这条线: //bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG]; 如果不知道你的程序的更广泛的上下文,我想这也可能 ...
  • 4.2.1中的越狱设备存在很多问题; 来自Xcode没有从设备收集4.2.1的符号,以及在调试时加载dylib的问题。 许多调试工具也不会在越狱设备上运行。 检查你是否在redsn0w中以系留模式启动,暂时在另一台设备上开发,或降级到4.1 / 4.0.1。 There are plenty of issues with Jailbroken devices at 4.2.1; from Xcode not collecting the Symbols for 4.2.1 from the device, ...
  • 好的,我修好了。 我的特定版本的linux,thermal_sys框架要求我们为get_crit_temp声明一个函数。 如果您没有定义它,它将在取消注册设备时尝试删除此设备文件,并且最终会出现NULL引用错误。 请注意,这不适用于3.0以上的Linux版本 Ok I fixed it. My specific version of linux, the thermal_sys framework requires us to have a function declared for get_crit_te ...
  • 事实证明我需要排除AirDrop才能在设备上运行。 activityVC.excludedActivityTypes = @[UIActivityTypeAirDrop]; 我不知道为什么会出现这种情况,因为我可以将AirDrop包含在其他项目中(在同一个iOS版本的同一设备上进行测试)。 可能有一些项目设置可能允许/禁止AirDrop。 这个答案对我有用,因为我不需要AirDrop用于我当前的项目,但如果有人能解释为什么UIActivityTypeAirDrop仅在我的项目中崩溃,我将不胜感激 Turn ...
  • 在使用logcat进行(大量)调试之后,我终于找到了问题。 mapview的父母之一将其宽度设置为0.显然mapview不喜欢这样,并决定重新启动平板电脑的时间。 由于mapview.getMap()不是异步的,我以前从未遇到过这种情况。 After (a huge amount of) debugging using logcat, I finally found the problem. One of the parents of the mapview gets it's width set to 0 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。