I have an HTML page that displays information on a given country. I would like now to generate this HTML with Java, so that then I can reuse the code for another HTML page and don't duplicate it.
I created this GET mapping in my controller
@RequestMapping(path = "/region/{regionId:[\\d]+}", produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public String regionPage(@PathVariable int regionId) {
return pageService.getRegionPage(regionId);
}
And the pageService.getRegionPage
returns for example the following String (that I formatted)
<!doctype html>
<html>
<head>
<title>Bhutan</title>
<script src="/angular/angular.min.js"></script>
<script src="/angular/angular-animate.js"></script>
<script src="/angular/angular-route.js"></script>
<script src="/angular/angular-cookies.js"></script>
<script src="/js/regionController.js"></script>
</head>
<body id="mainPage" ng-controller="regionController as controller" ng-cloak>
<div ng-include="'/html/regionContent.html'"></div>
</body>
</html>
I my browser, the javascript files are correctly downloaded. I also see that the title of the tab is "Bhutan". However the AngularJS does not execute and the page is blank.
How can I fix this? Thanks a lot
NB: If I create an HTML file containing this same HTML code, and serve it as
@RequestMapping(path = "/region/{regionId:[\\d]+}")
public String regionPage(@PathVariable int regionId) {
return "/region.html";
}
it works perfectly well
Via Active questions tagged javascript - Stack Overflow https://ift.tt/KLQ9IMF
Comments
Post a Comment