HTTP状态500 –内部服务器错误Spring Boot

时间:2020-09-21 11:00:20

标签: spring spring-boot

我正在spring boot中创建一个crud项目。每次我不知道如何解决时都会遇到此问题 到目前为止我尝试过的工作都附在下面的工作中,检查我的工作。我在github链接中附加的完整代码在这里 https://github.com/raguram1986/StudCrud

控制器

@Controller

public class StudentController {
    
     @Autowired
        private StudentService service;

        @GetMapping("/")
        public String viewHomePage(Model model) {
            List<Student> liststudent = service.listAll();
            model.addAttribute("liststudent", liststudent);
            System.out.print("Get / "); 
            return "index";
        }

        @GetMapping("/new")
        public String add(Model model) {
            model.addAttribute("student", new Student());
            return "new";
        }

index.html

  <tr>
            <div align = "left" >
               
                 <h3><a  th:href="@{'/new'}">Add new</a></h3>  
               
            </div>
        
        </tr>
        <tr>
        
        <div class="col-sm-5" align = "center">
                     <div class="panel-body" align = "center" >
                     
                     
                     <table class="table">
      <thead class="thead-dark">
        <tr>
                <th>Student ID</th>
                <th>Student Name</th>
                <th>Course</th>
                <th>Fee</th>
                <th>Edit</th>
                <th>Delete</th>
        </tr>
      </thead>
      <tbody>
          <tr  th:each="student : ${liststudent }">
            <td th:text="${student.id}">Student ID</td>
            <td th:text="${student.studentname}">StudentName</td>
            <td th:text="${student.course}">Course</td>
            <td th:text="${student.fee}">Fee</td>               
            <td>
                <a th:href="@{'/edit/' + ${student.id}}">Edit</a>
            </td>                               
            <td>
                <a th:href="@{'/delete/' + ${student.id}}">Delete</a>
            </td>           
            </tr> 
       
      </tbody>

我在代码下方附加了完全错误的错误

2020-09-21 16:34:43.091  INFO 18984 --- [           main] c.e.StudentCrud.StudentCrudApplication   : Starting StudentCrudApplication on kobinath-pc with PID 18984 (C:\Users\kobinath\eclipse-workspace1s\StudentCrud.zip_expanded\StudentCrud\target\classes started by kobinath in C:\Users\kobinath\eclipse-workspace1s\StudentCrud.zip_expanded\StudentCrud)
2020-09-21 16:34:43.095  INFO 18984 --- [           main] c.e.StudentCrud.StudentCrudApplication   : No active profile set, falling back to default profiles: default
2020-09-21 16:34:43.977  INFO 18984 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-09-21 16:34:44.072  INFO 18984 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 77ms. Found 1 JPA repository interfaces.
2020-09-21 16:34:45.068  INFO 18984 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9003 (http)
2020-09-21 16:34:45.084  INFO 18984 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-09-21 16:34:45.085  INFO 18984 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-09-21 16:34:45.282  INFO 18984 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-09-21 16:34:45.282  INFO 18984 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2110 ms
2020-09-21 16:34:45.560  INFO 18984 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-21 16:34:45.576  INFO 18984 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-09-21 16:34:45.789  INFO 18984 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-09-21 16:34:45.865  INFO 18984 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-21 16:34:46.106  INFO 18984 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-09-21 16:34:46.403  INFO 18984 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-09-21 16:34:46.570  WARN 18984 --- [           main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2020-09-21 16:34:46.677  INFO 18984 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2020-09-21 16:34:46.744  INFO 18984 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9003 (http) with context path ''
2020-09-21 16:34:46.747  INFO 18984 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-09-21 16:34:47.687  INFO 18984 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-09-21 16:34:47.699  INFO 18984 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-09-21 16:34:48.010  INFO 18984 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-09-21 16:34:48.023  INFO 18984 --- [           main] c.e.StudentCrud.StudentCrudApplication   : Started StudentCrudApplication in 5.445 seconds (JVM running for 5.976)
2020-09-21 16:35:13.335  INFO 18984 --- [nio-9003-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-09-21 16:35:13.335  INFO 18984 --- [nio-9003-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-09-21 16:35:13.345  INFO 18984 --- [nio-9003-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 10 ms
Get / 2020-09-21 16:35:13.912 ERROR 18984 --- [nio-9003-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-9003-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

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]

0 个答案:

没有答案