且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用SPRING MVC在JSP中显示图像

更新时间:2023-11-17 23:35:10

任何静态资源也在spring mvc中查找URL Mapping,因此应在 springmvc-servlet.xml中定义静态资源

Any static resource is also look for a URL Mapping in spring mvc, so static resources should be defined in the springmvc-servlet.xml.

将以下条目添加到MVC配置中。我假设你的静态文件在 resources 文件夹中。

Add the following entry to your MVC configuration. I assume that your static files in resources folder.

<mvc:resources mapping="/resources/**" location="/resources/" />

然后可以从页面访问静态文件。

then static files can be accessible from the page.

<img src="/resources/images/logo.jpg" />