Configure spring boot to redirect 404 to a single page app [duplicate]

This is the full Spring Boot 2.0 example: @Configuration public class WebApplicationConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController(“/notFound”).setViewName(“forward:/index.html”); } @Bean public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() { return container -> { container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, “/notFound”)); }; } }

Tell screen reader that page has changed in Backbone/Angular single-page app

Overall, you should not need to trigger a ‘re-read’, and depending on your UI that might not be a good thing anyway. My experience has been with angular.js (as an accessibility person rather than the developer), and our overall approach was to manage the focus rather than trigger a re-read. (We do extensive accessibility testing.) … Read more

mod_rewrite to index.html breaks relative paths for deep URLs

I got it to work and this is how: When you give the following as the src: <script src=”https://stackoverflow.com/questions/10865480/js/app/config.js”></script> you’re right in that Apache correctly reroutes to index.html (or whatever fallback URL you have) and then tries to access resources relatively according to nested path in the URL. To correct this, you need to have … Read more

Configure Spring Boot for SPA frontend

For routing, according to this guide at Using “Natural” Routes (specifically here), you have to add a controller that does the following: @Controller public class RouteController { @RequestMapping(value = “/{path:[^\\.]*}”) public String redirect() { return “forward:/”; } } Then using Spring Boot, the index.html loads at /, and resources can be loaded; routes are handled … Read more

How to use variable substitution in Frontend js applications like backend applications?

Complex applications developed with react, vue, angular or other javascript based frameworks has the same problem or requirement as backend applications (java, nodejs, python, etc): How read configurations? Here I will list some some approaches to work with configurations for javascritpt frameworks, from simple to manged solutions. Some of them are used for backend applications. … Read more

Print a div using javascript in angularJS single page application

$scope.printDiv = function(divName) { var printContents = document.getElementById(divName).innerHTML; var popupWin = window.open(”, ‘_blank’, ‘width=300,height=300’); popupWin.document.open(); popupWin.document.write(‘<html><head><link rel=”stylesheet” type=”text/css” href=”https://stackoverflow.com/questions/22189544/style.css” /></head><body onload=”window.print()”>’ + printContents + ‘</body></html>’); popupWin.document.close(); }

AngularJS HTML5 Mode – How do direct links work without server specific changes?

The AngularJS documentation does in fact mention this Server side Using this mode requires URL rewriting on server side, basically you have to rewrite all your links to entry point of your application (e.g. index.html) In this case, one Java-based solution is to tell the server “map all urls to index.html.” This can be done … Read more