Java Thymeleaf-本地文件作为图片
我的电脑上有一个样本图像Java Thymeleaf-本地文件作为图片,java,spring,spring-mvc,thymeleaf,Java,Spring,Spring Mvc,Thymeleaf,我的电脑上有一个样本图像 C:\Users\Jonatan\avatar\Koala.jpg 我想将其作为图像添加到HTML页面。我正在使用Thymeleaf,所以我想这样做 <img id="avatar" th:src="@{session.user.getUrlAvatar()}" class="avatar img-circle img-thumbnail" alt="avatar"> 我试图注册这个文件夹
C:\Users\Jonatan\avatar\Koala.jpg
我想将其作为图像添加到HTML页面。我正在使用Thymeleaf,所以我想这样做
<img id="avatar" th:src="@{session.user.getUrlAvatar()}"
class="avatar img-circle img-thumbnail" alt="avatar">
我试图注册这个文件夹
registry
.addResourceHandler("/avatar/**")
.addResourceLocations("file:///" + System.getProperty("user.home").replace("\\", "/"));
但仍然不起作用
有人知道怎么做吗?我只想使用驱动器C中的本地文件。必须计算链接的表达式,因此需要使用
${…}
:
registry
.addResourceHandler("/avatar/**")
.addResourceLocations("file:///" + System.getProperty("user.home").replace("\\", "/"));