I having an issue for get static resources in my jsp. I think my java configuration is well and i tried many solution for fix this problem but I didn't succeed.
Here, the dispatcher :
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/").setCachePeriod(3600)
.resourceChain(true).addResolver(new PathResourceResolver());
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public InternalResourceViewResolver jspViewResolver() {
InternalResourceViewResolver bean = new InternalResourceViewResolver();
bean.setPrefix("/WEB-INF/views/");
bean.setSuffix(".jsp");
return bean;
}
@Bean(name = "multipartResolver")
public CommonsMultipartResolver getMultipartResolver() {
return new CommonsMultipartResolver();
}
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource getMessageSource() {
ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
resource.setBasename("classpath:messages");
resource.setDefaultEncoding("UTF-8");
return resource;
}
Here web.xml
public void onStartup(ServletContext container) {
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ServiceConf.class, PersistenceConf.class, DaoConf.class);
// Manage the lifecycle of the root application context
container.addListener(new ContextLoaderListener(rootContext));
// Create the dispatcher servlet's Spring application context
AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
dispatcherServlet.register(AppMvcConf.class);
// Register and map the dispatcher servlet
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}[
Here the hierarchy where is my image:1
Call in my jsp :
<c:otherwise>
</c:otherwise>
</c:choose>
<img alt="img" src='<c:url value = "/resources/logo.jpg"></c:url>' />
</div>
</div>
</div>
When i launch Tomcat, all display correctly but not image, the link generate in "Developper Tool" when i see in console is :
<img src="myApp/resources/logo.jpg"/>
Can you help me to resolve this problem ? because i don't unknown the cause after several attempts for resolve it
Thank you