0

I am using spring boot to try and build my own mini website.

I have a controller

package hello;


import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class HelloController {


    @RequestMapping("/greeting")
    public String index() {
        return "index";
    }

}

and a html file resources/templates/index which I am trying to render but I just get the text "index" rendered. How can I return the html file instead of the text?

Eiko
  • 25,601
  • 15
  • 56
  • 71
user3057416
  • 105
  • 3
  • 11

1 Answers1

6

You have specified @RestController which says the result should be put into the @ResponseBody. You would want to use @Controller instead and then make sure you have a template framework (Thymeleaf, etc) in the classpath. Normally with most template frameworks you have to include the .html on the file that is within the templates folder.

Shawn Clark
  • 3,330
  • 2
  • 18
  • 30