如何用spring mvc将图像包含到jsp中

时间:2017-03-23 11:31:39

标签: jsp spring-mvc

我无法将图像显示在jsp页面中。

my webapp structure

我的配置类

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "it.gruppoaton")
public class AppConfig extends WebMvcConfigurerAdapter{

@Bean
public ViewResolver viewResolver() {
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setViewClass(JstlView.class);
    viewResolver.setPrefix("/");
    viewResolver.setSuffix(".jsp");
    return viewResolver;
}

@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/images/**").addResourceLocations("/images/").setCachePeriod(31556926);
}

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}

我的标题

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head style:background-color:>

<style>
    div{
        background-color: #0066ff;
    }
</style>
<div></div>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

</head>
<body>
<img align="left" src="<c:url value="/logoAtonBianco.png"/>" alt=""/>
</body>
</html>

我在这个网站上搜索了几个小时,看起来我已经完成了所有工作,但它仍然无法正常工作,无法显示任何内容。有什么建议吗?

0 个答案:

没有答案