我正在努力理解为什么通过浏览器打开网页时http://localhost:8080/1/reset-password/{hereComesToken}
使用intellij,这是我的资源文件夹:
已加载html内容,但未加载图像内容。
这是html图像标签:
<body>
<div class="content">
<img th:src="@{/images/image.jpg}" src="../static/images/image.jpg" alt="image not found"/>
</div><!-- CONTENT -->
</body>
我扩展了WebMvcConfigurationSupport
并添加了资源处理程序:
@Configuration
@EnableWebMvc
public class CustomMVCConfigurerAdapter extends WebMvcConfigurationSupport {
@Override
protected void addFormatters(FormatterRegistry registry) {
registry.addConverter(new ImageTypeConverter());
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String[] STATIC_RESOURCE = {"/", "classpath:/", "classpath:/META-INF/resources/", "classpath:/META-INF/resources/webjars/",
"classpath:/resources/", "classpath:/static/", "classpath:/public/"};
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(STATIC_RESOURCE);
}
}
}
我打开了网页源页面,这就是我得到的: