Jake Miller Jake Miller - 1 year ago 125
Java Question

Mapping html resources using Spring Boot

I'm using Spring Boot to create a REST API for a site I'm creating. Currently, to access static content, I simply go to the resources name. For example,

. Since I'm using REST controllers, there's no way to map pages to certain URL endings and there's no
file since I'm using Spring Boot. (for example, I want
to display the

Should I use standard MVC
controllers to control my page mapping or is there a better way to do this?


I can currently access static content by simply typing in the file name in the URL. (ex.
will open the index.)

What I want to know, is how to remap static content. For instance, if I want
to display
or if I want
to display
etc... It'll make it nicer/easier for a user to simply go to
instead of having to add the .html endings.

Is there a way to remap pages like this with Spring Boot?


I wish to have the burden of generating the views of each page placed upon the client's system. In other words, I do NOT want the server to generate each page. I wish to have "templates" essentially which are then turned into useful pages with information VIA a REST API utilized by AngularJS controllers.

Answer Source

If you want to use Angular, do not implement Thymeleaf (Thymeleaf is not RESTful). Then what you can do is use $routeProvider to specify what static resource to serve to which URI. If you have an index.html in your static dir, Spring Boot will automatically use that as the default page, and then your other static URI's used within Angular will be relative to the index page.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download