我将图像放在 /webapp/img/test.png 下,但它不会在 jetty 中渲染
我添加了一个 asset 文件夹和一个 images 子文件夹:
/webapp/assets/img
并在里面放置了一个 test.png 文件。
在我的 index.jsp 页面中,我放置了一个 img 标签:
<img src="/assets/img/test.png" alt="" />
The image doest' render, I run:
mvn clean install
mvn jetty:run
在终端窗口的输出中,我看到:
20:30:42,905 WARN PageNotFound:947 - 没有找到 HTTP 请求的映射DispatcherServlet 中名称为“myapp”的 URI [/assets/img/test.png]
我也看到 favicon.ico 出现相同的错误(我没有'这样的错误) 感觉)。
我需要调整 web.xml 文件中的某些内容吗?
(这是一个spring mvc应用程序)
I added a assets folder and an a images subfolder:
/webapp/assets/img
And inside I put a test.png file.
From inside my index.jsp page, I put a img tag:
<img src="/assets/img/test.png" alt="" />
The image doesnt' render, I ran:
mvn clean install
mvn jetty:run
In the output in my terminal window I see:
20:30:42,905 WARN PageNotFound:947 - No mapping found for HTTP request with URI [/assets/img/test.png] in DispatcherServlet with name 'myapp'
I also see the same error for favicon.ico (I dont' have one so that one makes sense).
Do I need to adjust something in my web.xml file?
(This is a spring mvc app)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能已将 Spring servlet 配置为映射到
/
,这意味着它处理对 Web 应用程序的所有请求。要么将其仅映射到某些请求(例如 *.htm、*.action 或其他),要么 配置 Spring 提供静态资源。You have probably configured the Spring servlet to be mapped to
/
, which means it handles all the requests to the web app. Either map it to only certain requests (like *.htm, *.action, or whatever), or configure Spring to serve static resources.