43 lines
1.4 KiB
Java
Raw Normal View History

2018-11-05 21:33:19 +02:00
package com.baeldung.spring;
2013-05-01 15:12:58 +03:00
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
2013-05-01 15:12:58 +03:00
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;
2013-05-01 15:12:58 +03:00
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
@EnableWebMvc
@Configuration
public class MvcConfig implements WebMvcConfigurer {
2013-05-01 15:12:58 +03:00
2013-06-02 19:10:14 +03:00
public MvcConfig() {
2013-05-23 23:25:53 +03:00
super();
}
2013-05-01 15:12:58 +03:00
2013-05-23 23:25:53 +03:00
// API
2013-05-01 15:12:58 +03:00
2013-05-23 23:25:53 +03:00
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
2013-05-01 15:12:58 +03:00
2013-05-23 23:25:53 +03:00
registry.addViewController("/anonymous.html");
registry.addViewController("/login.html");
registry.addViewController("/homepage.html");
registry.addViewController("/admin/adminpage.html");
registry.addViewController("/accessDenied");
2013-05-23 23:25:53 +03:00
}
2013-05-01 15:12:58 +03:00
2013-05-23 23:25:53 +03:00
@Bean
public ViewResolver viewResolver() {
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
2013-05-01 15:12:58 +03:00
2013-05-23 23:25:53 +03:00
bean.setViewClass(JstlView.class);
bean.setPrefix("/WEB-INF/view/");
bean.setSuffix(".jsp");
return bean;
}
2013-05-01 15:12:58 +03:00
}