I'm using Spring Boot 2.5.2. I configured all things (not security, it is auto configured and need to convert all configuration from XML to Java. Authentication is working via LDAP) and working correctly except one thing i.e. mapping to / -> redirect:/main.
Note: This is a migration from Spring to Spring Boot with .jsp as view.
Below is the mapping in XML:
<mvc:view-controller path="/" view-name="redirect:/main" />
Above is working correctly in Spring but when converted to Spring Boot using Java code as below then this specific case is not working:
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("redirect:/main");
}
}
Note: If I set addViewController something else like /documentation then it is redirecting successfully but not with /.