samedi 17 février 2018

How to return html on get method in Spring app?

I have maybe very ease question, I already using Spring mvc + jsp, but now I can not understand why the controller does not return the html file. Now I use Spring Boot with the 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";
}

And my html file:

    <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HelloWorld</title>
</head>
<body>
HELLO
</body>
</html>

I always get error: Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sat Feb 17 20:22:24 EET 2018 There was an unexpected error (type=Not Found, status=404). No message available




Aucun commentaire:

Enregistrer un commentaire