第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > thymeleaf 使用页面报错_SpringBoot 使用thymeleaf 跳转页面时 总是提示404找不到页面...

thymeleaf 使用页面报错_SpringBoot 使用thymeleaf 跳转页面时 总是提示404找不到页面...

时间:2020-04-02 10:02:44

相关推荐

thymeleaf 使用页面报错_SpringBoot 使用thymeleaf 跳转页面时 总是提示404找不到页面...

Thymeleaf的使用和版本关系很大,如果路径配置正确却一直无法正常返回,可能就是版本错误导致。

想构建简单页面跳转,正常跳转index.html,404和500跳转到专门的页面,配置正确,路径也正确,controller的方法也能访问到,但是一直无法正常跳转,页面报404.修改版本后,可以正常访问。

修改前:

@Controllerpublic classIndexController {

@GetMapping("/")publicString index() {//int i = 9 / 0;

System.out.println("HelloWorld!");return "index";

}

}

访问:localhos:8080,报错:404

记录一下目前可以正常使用的版本(-12-23)

UTF-8

UTF-8

1.8

3.0.11.RELEASE

3.0.0

修改后:

Controller(index):

@Controllerpublic classIndexController {

@GetMapping("/")publicString index() {//int i = 9 / 0;

return "index";

}

}

Controller(500):

@Controllerpublic classIndexController {

@GetMapping("/")publicString index() {int i = 9 / 0;return "index";

}

}

测试404只需在导航栏输入不存在的路径,例如:http://localhost:8080/aaaa

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。