43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
package com.baeldung.spring;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.ViewResolver;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
import org.springframework.web.servlet.view.JstlView;
|
|
|
|
@EnableWebMvc
|
|
@Configuration
|
|
public class MvcConfig implements WebMvcConfigurer {
|
|
|
|
public MvcConfig() {
|
|
super();
|
|
}
|
|
|
|
// API
|
|
|
|
@Override
|
|
public void addViewControllers(final ViewControllerRegistry registry) {
|
|
|
|
registry.addViewController("/anonymous.html");
|
|
registry.addViewController("/login.html");
|
|
registry.addViewController("/homepage.html");
|
|
registry.addViewController("/admin/adminpage.html");
|
|
registry.addViewController("/accessDenied");
|
|
}
|
|
|
|
@Bean
|
|
public ViewResolver viewResolver() {
|
|
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
|
|
|
bean.setViewClass(JstlView.class);
|
|
bean.setPrefix("/WEB-INF/view/");
|
|
bean.setSuffix(".jsp");
|
|
|
|
return bean;
|
|
}
|
|
} |