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;
|
2018-11-04 17:47:39 +05:30
|
|
|
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;
|
2018-11-04 17:47:39 +05:30
|
|
|
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
|
2018-11-04 17:47:39 +05:30
|
|
|
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");
|
2016-12-29 15:55:40 -07:00
|
|
|
registry.addViewController("/admin/adminpage.html");
|
2017-02-12 16:11:55 +02:00
|
|
|
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
|
|
|
}
|