Commit 152d55c2 authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

Bug on rendering 404 error page

parent 1bf4f6d6
......@@ -52,7 +52,7 @@ public class UserControllerAdvice extends BaseController {
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(value = { ResourceNotFoundException.class, NoHandlerFoundException.class })
public ModelAndView handleResourceNotFoundException(final ResourceNotFoundException e) {
public ModelAndView handleResourceNotFoundException(final Exception e) {
final ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
......
......@@ -18,7 +18,6 @@ package org.genesys2.spring.config;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
......@@ -48,7 +47,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.validation.Validator;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
......@@ -56,7 +54,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
import org.springframework.web.servlet.theme.CookieThemeResolver;
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
......@@ -86,16 +83,6 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
@Resource
private Set<String> supportedLocales;
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver() {
final Properties properties = new Properties();
properties.setProperty("javax.servlet.UnavailableException", "/404");
final SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver();
resolver.setExceptionMappings(properties);
return resolver;
}
@Scope("singleton")
@Bean
@Override
......@@ -133,11 +120,6 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
super.addViewControllers(registry);
}
@Override
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void configurePathMatch(final PathMatchConfigurer configurer) {
configurer.setUseTrailingSlashMatch(true);
......
......@@ -31,8 +31,10 @@ import org.genesys2.server.servlet.filter.NewGUIFilter;
import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.sitemesh.webapp.contentfilter.BasicSelector;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter;
import org.tuckey.web.filters.urlrewrite.gzip.GzipFilter;
......@@ -62,6 +64,13 @@ public class WebInitializer extends AbstractAnnotationConfigDispatcherServletIni
return null;
}
@Override
protected DispatcherServlet createDispatcherServlet(final WebApplicationContext servletAppContext) {
final DispatcherServlet dispatcherServlet = (DispatcherServlet) super.createDispatcherServlet(servletAppContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
return dispatcherServlet;
}
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment