Created
December 17, 2017 21:51
-
-
Save TwiN/28f4f5037ecd9102775f5172984500fc to your computer and use it in GitHub Desktop.
Link a React app using React-Router and bundled with Webpack to a Spring Boot app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.twinnation.site; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | |
@Configuration | |
public class WebConfiguration { | |
@Bean | |
public WebMvcConfigurerAdapter forwardToIndex() { | |
return new WebMvcConfigurerAdapter() { | |
@Override | |
public void addViewControllers(ViewControllerRegistry registry) { | |
registry.addViewController("/").setViewName("forward:/index.html"); | |
registry.addViewController("/{spring:\\w+}").setViewName("forward:/"); | |
registry.addViewController("/**/{spring:\\w+}").setViewName("forward:/"); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment