springboot中controller类的return无法实现页面跳转

问题:在Controller中return 直接返回了字符串,并没有跳转到html网页
@RestController
public class HelloController {

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String helloSpringBoot(){
        return "Hello SpringBoot!";
    }


    @Autowired
    private Developer developer;
    @RequestMapping(value = "/developer", method = RequestMethod.GET)
    public String showDeveloper(){
        return developer.toString();
    }

    @RequestMapping(value = {"/t", "/temp", "/template"}, method = RequestMethod.GET)
    public String showIndexHtml(Model model){
        return "index";
    }

}

1, 检查resources/templates下的index.html是否存在
2, 检查配置文件的thymeleaf配置

我这把@RestController改成@Controller就可以使用了

你可能感兴趣的:(Java)