Answer the question
In order to leave comments, you need to log in
How to return html page in Spring Boot?
Good evening
Terribly stupid question, I already wrote using Spring mvc + jsp, but now I can’t understand why the controller doesn’t just return an html document. Here is Spring Boot with Web module.
@Controller
@RequestMapping(value = "/test")
public class Main {
private static final Logger logger = Logger
.getLogger(Main.class.getName());
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String index() {
return "templates/hello.html";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HelloWorld</title>
</head>
<body>
HELLO
</body>
</html>
Answer the question
In order to leave comments, you need to log in
In spring-boot, you don't need to write a controller for a static page.
All static content (if it's a jar) should be in "resources/static/".
If you want the web components to be in "webapp/", then indicate that you are building war, not jar.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question