2023-11-27 21:08:28 -08:00
|
|
|
package com.wisemapping.config.mvc;
|
2023-11-26 16:13:45 -08:00
|
|
|
|
2024-01-16 21:24:21 -08:00
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
2023-11-27 21:08:28 -08:00
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
2023-11-26 16:13:45 -08:00
|
|
|
import org.springframework.context.annotation.Bean;
|
2023-11-27 21:08:28 -08:00
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
2024-01-16 21:24:21 -08:00
|
|
|
import org.springframework.context.annotation.Configuration;
|
2023-11-26 16:13:45 -08:00
|
|
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
|
|
|
import org.springframework.web.servlet.ViewResolver;
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
2023-11-27 21:47:22 -08:00
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
2023-11-26 16:13:45 -08:00
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
|
|
|
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
|
|
import org.springframework.web.servlet.view.JstlView;
|
|
|
|
|
2023-11-27 21:08:28 -08:00
|
|
|
|
2024-01-16 21:24:21 -08:00
|
|
|
@Configuration
|
|
|
|
@EnableAutoConfiguration
|
2023-11-26 16:13:45 -08:00
|
|
|
@EnableWebMvc
|
2023-11-27 21:08:28 -08:00
|
|
|
@ComponentScan("com.wisemapping.webmvc")
|
|
|
|
public class MvcAppConfig implements WebMvcConfigurer {
|
2023-11-27 21:47:22 -08:00
|
|
|
@Override
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
registry
|
|
|
|
.addResourceHandler("/**")
|
|
|
|
.addResourceLocations("classpath:/public/");
|
|
|
|
}
|
2023-11-26 16:13:45 -08:00
|
|
|
|
|
|
|
@Bean
|
|
|
|
public ViewResolver viewResolver() {
|
|
|
|
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
2023-11-27 21:08:28 -08:00
|
|
|
resolver.setPrefix("/WEB-INF/jsp/");
|
2023-11-26 16:13:45 -08:00
|
|
|
resolver.setSuffix(".jsp");
|
|
|
|
resolver.setViewClass(JstlView.class);
|
|
|
|
return resolver;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
HandlerExceptionResolver errorHandler() {
|
|
|
|
final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver();
|
|
|
|
|
|
|
|
//mapping status code with view response.
|
|
|
|
result.addStatusCode("reactInclude", 403);
|
|
|
|
|
|
|
|
//setting default error view
|
|
|
|
result.setDefaultErrorView("reactInclude");
|
|
|
|
result.setDefaultStatusCode(500);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|