I have a web application (package.jar) which runs with embedded tomcat. Now, I need to add a controller (e.g: http://localhost:8080/package/demo) which will load HTML/javascript/css from an external folder (e.g: /var/www/html/demo) which this web application can read files.
I cannot add them to package.jar as these external files can be updated later and the web-application should return all static contents as they are!
I tried to create a simple RestController which points to /var/www/html/demo/index.html
, e.g:
@RestController
public class DemoController {
@RequestMapping("/")
public String handle() throws IOException {
File file = new File("/var/www/html/demo/index.html");
return FileUtils.readFileToString(file);
}
}
The problem is it cannot request any assets (like: CSS/Javascript files) from /var/www/html/demo/
as they don't exist as resources inside package.jar (e.g: http://localhost:8080/package/assets/js/config.js)
Do you have any suggestions to do it? Thanks