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?

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I know i am not supposed to say thanks but thanks it did exactly want i wanted

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.