Commit 5d4dc120 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

fixed redirect issue

parent 2410790a
Pipeline #11752 failed with stage
in 8 minutes and 13 seconds
...@@ -2,11 +2,14 @@ package lcsb.mapviewer.web.config; ...@@ -2,11 +2,14 @@ package lcsb.mapviewer.web.config;
import lcsb.mapviewer.api.SpringRestApiConfig; import lcsb.mapviewer.api.SpringRestApiConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import java.util.List; import java.util.List;
...@@ -23,14 +26,26 @@ public class SpringWebConfig implements WebMvcConfigurer { ...@@ -23,14 +26,26 @@ public class SpringWebConfig implements WebMvcConfigurer {
this.interceptors = interceptors; this.interceptors = interceptors;
} }
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/");
resolver.setSuffix(".xhtml");
return resolver;
}
@Override @Override
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/", "/index.xhtml"); registry
.addViewController("/")
.setViewName("index");
} }
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
} }
@Override @Override
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; url=index.xhtml" />
<p><a href="index.xhtml">Redirect</a></p>
</head>
<body>
</body>
</html>
\ No newline at end of file
...@@ -135,7 +135,7 @@ public class SpringSecurityGeneralIntegrationTest extends ControllerIntegrationT ...@@ -135,7 +135,7 @@ public class SpringSecurityGeneralIntegrationTest extends ControllerIntegrationT
public void testAllowCacheForRootReuqest() throws Exception { public void testAllowCacheForRootReuqest() throws Exception {
RequestBuilder request = get("/"); RequestBuilder request = get("/");
MockHttpServletResponse response = mockMvc.perform(request) MockHttpServletResponse response = mockMvc.perform(request)
.andExpect(status().is3xxRedirection()) .andExpect(status().is2xxSuccessful())
.andReturn().getResponse(); .andReturn().getResponse();
assertFalse(response.getHeaderNames().contains("Pragma")); assertFalse(response.getHeaderNames().contains("Pragma"));
assertFalse(response.getHeaderNames().contains("Vary")); assertFalse(response.getHeaderNames().contains("Vary"));
......
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