首页 文章

运行时出错:http:// localhost:8080

提问于
浏览
0

当我运行Spring的1个项目时,我有1个bug . 创建类通用:BlogMvcApplication.java

package blog;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

    @SpringBootApplication
    public class BlogMvcApplication {
        public static void main(String[] args) {
            SpringApplication.run(BlogMvcApplication.class, args);
        }
    }

2-创建类控件:HomeController.java

package blog.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {
@RequestMapping("/")
    public String index() {
        return "index";
    }
}

3-视图:index.html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8" />
    <title>Blog</title>
</head>

<body>
<h1>Welcome to Spring MVC</h1>
    Now is: <b th:text="${execInfo.now.time}"></b>
</body>

</html>

访问http://localhost:8080时出错:

2017-03-02 00:55:41.931 ERROR 1068 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "index": Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers

2017-03-02 00:55:41.958 ERROR 1068 --- [nio-8080-exec-1] oaccC [ . [ . [/] . [dispatcherServlet]:servlet [dispatcherServlet]的Servlet.service()与上下文有关path []引发异常[请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateInputException:解析模板“index”时出错,模板可能不存在或任何已配置的模板解析器可能无法访问

org.thymeleaf.exceptions.TemplateInputException:解析模板“index”时出错,模板可能不存在或者可能无法被org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246)中的任何已配置模板解析器访问〜[thymeleaf- 2.1.5.RELEASE.jar:2.1.5.RELEASE] org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104)〜[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org . thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)〜[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)~ [thymeleaf-2.1 .5.RELEASE.jar:2.1.5.RELEASE]

我认为错误,因为重复端口8080启动时请帮助修复bug谢谢!

1 回答

  • 0

    我不认为这个错误是由于端口上的重复造成的 . 如果是问题,那么你无法启动你的应用程序,并会看到这样的消息:“....端口8080无法启动” .

    当看到你的index.html在默认位置找不到:/src/main/resources/templates/index.html当百万富翁引擎试图解析你所请求的模板时 .

    希望能帮助到你 .

相关问题