/** * This file is part of General Entity Annotator Benchmark. * * General Entity Annotator Benchmark is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * General Entity Annotator Benchmark is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with General Entity Annotator Benchmark. If not, see <http://www.gnu.org/licenses/>. */ package org.aksw.gerbil.web.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; /** * This {@link Configuration} class handles the initialization of the MVC elements. * * @author Michael Röder (roeder@informatik.uni-leipzig.de) * @author Lars Wesemann * @author Didier Cherix * */ @Configuration @EnableWebMvc @ComponentScan(basePackages = { "org.aksw.gerbil.utils", "org.aksw.gerbil.web", "org.aksw.gerbil.datasets.datahub" }) public class WebMvcConfig extends WebMvcConfigurerAdapter { private static final transient Logger logger = LoggerFactory.getLogger(WebMvcConfig.class); /** * @return the view resolver */ @Bean public ViewResolver viewResolver() { logger.debug("setting up view resolver"); InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setPrefix("/WEB-INF/views/"); viewResolver.setSuffix(".jsp"); return viewResolver; } @Bean public CommonsMultipartResolver multipartResolver() { return new CommonsMultipartResolver(); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/webResources/**").addResourceLocations("classpath:webResources/"); registry.addResourceHandler("/dataId/corpora/**").addResourceLocations("classpath:dataId/corpora/"); registry.addResourceHandler("/dataId/annotators/**").addResourceLocations("classpath:dataId/annotators/"); } }