Images from solutions are loading again

This commit is contained in:
Nanne Baars
2016-04-09 13:36:06 +02:00
parent 8ff02cab6d
commit a8ea4a16e6
12 changed files with 79 additions and 308 deletions

View File

@ -5,9 +5,15 @@ import org.owasp.webgoat.session.WebgoatContext;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.io.File;
import java.io.IOException;
/**
*
*/
@ -25,6 +31,18 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter {
return new ServletRegistrationBean(hammerHead, "/attack/*");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
Resource resource = new ClassPathResource("/plugin_lessons/plugin_lessons_marker.txt");
try {
File pluginsDir = resource.getFile().getParentFile();
registry.addResourceHandler("/plugin_lessons/**").addResourceLocations("file:///" + pluginsDir.toString() + "/");
} catch (IOException e) {
e.printStackTrace();
}
}
@Bean
public HammerHead hammerHead(WebgoatContext context) {
return new HammerHead(context);