java - How to make an html-file appear on localhost with Spring Boot? -


i using spring boot , have html-file "index.html", , have class "functions". basically, want happen when functions-class run, , when go localhost:8080, html-template appears @ localhost. how should this?

here segment of functions-class:

public class functions{    @requestmapping("/")    public void gethomepage(){       //return html-template    } 

}

the html-file called "index.html" , in src/main/resources/static-folder.

thank you!

first of all, put index.html template file in src/main/resources/templates instead of in src/main/resources/static.

your class functions must spring mvc controller; can make controller adding @controller annotation. return name of template in gethomepage() method:

@controller public class functions {     @requestmapping("/")     public string gethomepage() {         return "index";     } } 

this basic spring web mvc; see tutorial serving web content guide on spring website , reference documentation.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -