Created
April 16, 2012 09:12
-
-
Save keesun/2397205 to your computer and use it in GitHub Desktop.
Web configuration using @configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cantabille.config; | |
import cantabille.modules.ModulesPackageMarker; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.servlet.HandlerMapping; | |
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; | |
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; | |
import org.springframework.web.servlet.view.InternalResourceViewResolver; | |
import org.springframework.web.servlet.view.JstlView; | |
/** | |
* @author Keesun Baik | |
*/ | |
@Configuration | |
@ComponentScan( | |
basePackageClasses = ModulesPackageMarker.class, | |
useDefaultFilters = false, | |
includeFilters = @ComponentScan.Filter(Controller.class)) | |
public class WebConfig extends WebMvcConfigurationSupport { | |
@Override | |
protected void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { | |
configurer.enable(); | |
} | |
@Override | |
protected void addResourceHandlers(ResourceHandlerRegistry registry) { | |
registry.addResourceHandler("/resources/**").addResourceLocations("/static"); | |
} | |
@Bean | |
public InternalResourceViewResolver viewResolver() { | |
InternalResourceViewResolver resolver = new InternalResourceViewResolver(); | |
resolver.setViewClass(JstlView.class); | |
resolver.setPrefix("/WEB-INF/views/"); | |
resolver.setSuffix(".jsp"); | |
return resolver; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment