如何从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
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
原文:https://stackoverflow.com/questions/36928098
最满意答案
好的,我修好了。 我的特定版本的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包中的活动。 像这样重写你的主题:
-
UITableView崩溃(UITableView Crashes)[2023-01-30]
如果单元格从tableview成功出列,则忽略将指针bottomLabel设置为任何特定值,然后隐式取消引用它。 如果你真的不希望它在单元格出列时指向任何东西,那么将它初始化为指向nil: UITextView *bottomLabel = nil; 在Objective-C中向nil发送消息总是安全的。 你已经注释掉了这条线: //bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG]; 如果不知道你的程序的更广泛的上下文,我想这也可能 ... -
部署到设备时,带有iOS 4.2的xcode 3.2.5崩溃(xcode 3.2.5 with iOS 4.2 crashes when deploying to device)[2022-08-11]
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, ... -
执行thermal_zone_device_unregister()时内核崩溃(Kernel crashes when doing thermal_zone_device_unregister())[2023-09-01]
好的,我修好了。 我的特定版本的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 ... -
UIActivityViewController在设备上显示时崩溃(UIActivityViewController crashes when presented on device)[2021-07-20]
事实证明我需要排除AirDrop才能在设备上运行。 activityVC.excludedActivityTypes = @[UIActivityTypeAirDrop]; 我不知道为什么会出现这种情况,因为我可以将AirDrop包含在其他项目中(在同一个iOS版本的同一设备上进行测试)。 可能有一些项目设置可能允许/禁止AirDrop。 这个答案对我有用,因为我不需要AirDrop用于我当前的项目,但如果有人能解释为什么UIActivityTypeAirDrop仅在我的项目中崩溃,我将不胜感激 Turn ... -
getMapAsync崩溃了设备(getMapAsync crashes device)[2023-08-30]
在使用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 ...