Spring MVC 错误记录
根据https://spring.io/guides/gs/serving-web-content/ 的步骤,运行后输入http://localhost:8080/hello 或http://localhost:8080/hello?name=sdaa 等
出现错误(网页出现http 500错误):
javax.servlet.ServletException: Circular view path []: would dispatch back to the c
参考https://blog.csdn.net/RuigeO/article/details/83926287?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control
修改view和path使他们不同名。错误看似消除。但刷新网页出现http 404错误(There was an unexpected error (type=Not Found, status=404).),再次查找核对。(https://stackoverflow.com/questions/36819277/issue-with-spring-there-was-an-unexpected-error-type-not-found-status-404)
最后发现问题出在pom文件中,虽然加入了thymeleaf依赖,但我在复制时候多了一行 scope:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <scope>test</scope> </dependency>
去掉scope:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
程序完美运行,网页正常返回hello+字符。