简体   繁体   English

springboot项目的问题:org.thymeleaf.exceptions.TemplateInputException

[英]issue with springboot project : org.thymeleaf.exceptions.TemplateInputException

hey guys 大家好
i have a problem in my java spring boot application 我的Java Spring Boot应用程序中有问题
i've built a simple application and connected it with a database 我建立了一个简单的应用程序并将其与数据库连接
but when i try to make a POST or GET on the data base my program access the database and do any thing i did but show an error 但是,当我尝试在数据库上进行POST或GET时,我的程序访问数据库并执行我所做的任何事情,但显示错误
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Students", template might not exist or might not be accessible by any of the configured Template Resolvers org.thymeleaf.exceptions.TemplateInputException:解决模板“学生”时出错,模板可能不存在或任何已配置的模板解析器都无法访问

when i make GET i check the Iterable list and it's already get the data from database but doesn't show the data on the localhost it's give me that exception is there any solution for that ? 当我执行GET时,我检查了Iterable列表,它已经从数据库中获取了数据,但是没有在本地主机上显示数据,这给了我例外是否有解决方案? this is my code in controller 这是我在控制器中的代码

@Path("Students")
@Controller
public class studentsController {
    @AutoWired
    StudentServices st;
    @RequestMapping(method = RequestMethod.GET)
    public Iterable<Students> getAllStudents() {
          Iterable<Students> list = st.getAllStudents();
          return list
}

With @Controller you are defining a Model-View-Controller (MVC) endpoint for returning your view templates. 使用@Controller,您可以定义一个Model-View-Controller(MVC)端点来返回视图模板。 So with Iterable<Students> Spring is looking for a Students template in your src/main/resources/templates folder because it is interpreted as a View name. 因此,使用Iterable<Students> Spring会在src/main/resources/templates文件夹中寻找“ Students模板,因为它被解释为“视图”名称。

If you want to create a REST endpoint which returns a list of Student objects you should use @RestController at your class which adds the Spring annotation @RequestBody automatically. 如果要创建一个返回学生对象列表的REST端点, @RestController在类中使用@RestController ,该类会自动添加Spring批注@RequestBody

Furthermore @Path("XYZ") should be replaced with @RequestMapping("XYZ") in Spring and @AutoWired with @Autowired . 此外,Spring中的@Path("XYZ")应该替换为@RequestMapping("XYZ") ,而@AutoWired应该替换为@Autowired

An working example could look like the following: 一个有效的示例如下所示:

@RequestMapping("/students")
@RestController
public class StudentsController {

    @Autowired
    StudentServices st;

    @RequestMapping(value="/", method = RequestMethod.GET)
    public Iterable<Students> getAllStudents() {
          Iterable<Students> list = st.getAllStudents();
          return list
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Thymeleaf:org.thymeleaf.exceptions.TemplateInputException - Thymeleaf : org.thymeleaf.exceptions.TemplateInputException 如何调试org.thymeleaf.exceptions.TemplateInputException? - How to debug org.thymeleaf.exceptions.TemplateInputException? org.thymeleaf.exceptions.TemplateInputException:Spring Boot - org.thymeleaf.exceptions.TemplateInputException: Spring Boot Thyemleaf 嵌套迭代触发器 org.thymeleaf.exceptions.TemplateInputException - Thyemleaf nested iteration triggers org.thymeleaf.exceptions.TemplateInputException org.thymeleaf.exceptions.TemplateInputException:解决片段错误:无法解析模板或片段 - org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: template or fragment could not be resolved 我的spring-boot应用程序给出以下错误“ org.thymeleaf.exceptions.TemplateInputException:” - My spring-boot app gives the following error “org.thymeleaf.exceptions.TemplateInputException:” org.thymeleaf.exceptions.TemplateInputException:异常分析文档:template =“ login”,第36行-第3列 - org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template=“login”, line 36 - column 3 如何摆脱 org.thymeleaf.exceptions.TemplateInputException: 同时使用 thymeleaf 表达式以引导卡的形式打印数据? - how to get rid of org.thymeleaf.exceptions.TemplateInputException: while using thymeleaf expression to print data in form of bootstrap cards? thymeleaf + springboot + springsecurity 项目配置 - thymeleaf + springboot + springsecurity project configuration org.thymeleaf.exceptions.TemplateProcessingException:串联 href - org.thymeleaf.exceptions.TemplateProcessingException: Concatenation href
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM