spring boot return string instead of .html file

后端 未结 4 2112
无人共我
无人共我 2021-02-15 10:59

I tried to run spring boot application, that will return me the HTML static file on the static folder, the problem was: every time I load the page: 127.0.0.1 I get the String \"

4条回答
  •  萌比男神i
    2021-02-15 11:24

    @Controller VS @RestController

    • @Controller is used to mark classes as Spring MVC Controller.
    • @RestController is a convenience annotation that does nothing more than adding the @Controller and @ResponseBody annotations.

    So in your case just removing the @ResponseBody annotation from the welcome() method in HomeController.java, should be enough to get the desired output.

    Also have a look at this Spring Guide displaying how to Serve Web Content with Spring MVC

提交回复
热议问题