Commit 60a14e8f authored by Aleksandr Sharaban's avatar Aleksandr Sharaban
Browse files

Complete removal of web.xml

parent 2533a5d7
......@@ -45,8 +45,11 @@ public class WebAppInitializer implements WebApplicationInitializer {
private void registerServlets(ServletContext servletContext, AnnotationConfigWebApplicationContext appContext) {
//Dispatcher servlet configuration
DispatcherServlet dispatcher = new DispatcherServlet(appContext);
dispatcher.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic dispatcherServlet = servletContext
.addServlet("mvc", new DispatcherServlet(appContext));
.addServlet("mvc", dispatcher);
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.addMapping("/");
......@@ -85,7 +88,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
encodingFilter.setInitParameter("encoding", "UTF-8");
encodingFilter.setInitParameter("forceEncoding", "true");
urlRewriteFilter.addMappingForUrlPatterns(null, false, "/*");
encodingFilter.addMappingForUrlPatterns(null, false, "/*");
//Configuration of cross origin filter for web REST API clients
FilterRegistration.Dynamic crossOriginFilter = servletContext
......
......@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.NoHandlerFoundException;
@ControllerAdvice
public class UserControllerAdvice extends BaseController {
......@@ -80,6 +81,11 @@ public class UserControllerAdvice extends BaseController {
return transformErrors(e.getBindingResult());
}
@ExceptionHandler(value = { NoHandlerFoundException.class })
public ModelAndView handle404() {
return new ModelAndView("/errors/404");
}
private Map<String, String> transformErrors(Errors errors) {
final Map<String, String> errorsMap = new HashMap<String, String>();
......
......@@ -85,11 +85,6 @@ public class SpringServletConfig extends WebMvcConfigurerAdapter {
return resolver;
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
final ThemeChangeInterceptor themeChangeInterceptor = new ThemeChangeInterceptor();
......
......@@ -37,18 +37,6 @@
</style>
</head>
<body>
<div class="header">
<div class="container">
<a href="<c:url value="/" />" class="logo"><img src="<c:url value="/html/0/images/logo_genesys.png" />" alt="Genesys - Gateway to Genetic Resources" /></a>
</div>
</div>
<div class="menu">
<div class="container">
<a href="<c:url value="/" />">Home</a>
</div>
</div>
<div class="container">
<div class="content">
<div class="error-title"><span>404</span>error</div>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014 Global Crop Diversity Trust
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<error-page>
<error-code>401</error-code>
<location>/errors/401</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/errors/404</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/errors/500</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/errors/503</location>
</error-page>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
</web-app>
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