我正在使用Maven + Spring构建一个应用程序,webapp原型
在图像中有我的目录树。 图像位于webapp / public目录
中它们在/ svgTest / public / images
中正确部署在tomcat中我尝试以这种方式在我的jsp页面中链接它们:
<img src="<%=request.getContextPath() %>/public/images/disegno.svg" />
链接正确,但在日志中我看到了
2016-03-02 11:52:33.192 DEBUG [http-nio-8080-exec-55]: Looking up handler method for path /public/images/disegno.svg
2016-03-02 11:52:33.192 DEBUG [http-nio-8080-exec-55]: Did not find handler method for [/public/images/disegno.svg]
2016-03-02 11:52:33.192 WARN [http-nio-8080-exec-55]: No mapping found for HTTP request with URI [/svgTest/public/images/disegno.svg] in DispatcherServlet with name 'dispatcher'
我的AppConfig.java非常简单:
@Configuration
@EnableWebMvc
@ComponentScan("it.besmart")
public class AppConfig extends WebMvcConfigurerAdapter{
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/pages/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
}
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Bean(name = "multipartResolver")
public StandardServletMultipartResolver resolver() {
return new StandardServletMultipartResolver();
}
@Bean
public SVGParser parser(){
return new SVGParser();
}
}
这是我的AppInitializer.java
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { AppConfig.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
缺少什么?
答案 0 :(得分:0)
尝试使用此结构
web应用资源图像-xyz.svg