模板分析期间出错(模板:“Class path resource[templates/index.html]”)org.thymeleaf.exceptions.templateInputException:模板分析期间出错(模板:“Class path resource[templates/index.html]”),原因是:org.attoparser.ParseException:计算SpringEL表达式“car.getInstructor().id”(模板:“index”-第84行,第13栏)
在Instructor class中,
@OneToOne(cascade=CascadeType.All,fetch=FetchType.Lazy)private Car;在汽车课上,我做了这个@OneToone私人指导员指导员;
<body>
<form th:object="${instructor}" th:action="@{/instructor/}" method="post">
<input type="hidden" th:field="*{id}"/>
First name<br>
<input type="text" class="form-control" th:field="*{firstName}"/><br>
Last name <br>
<input type="text" class="form-control" th:field="*{lastName}"/><br>
City <br>
<input type="text" class="form-control" th:field="*{city}"/><br>
Address <br>
<input type="text" class="form-control" th:field="*{address}"/><br>
<input type="number" class="form-control" th:field="*{car.id}"/><br>
<button type="submit">Submit</button>
</form>
</body>
@slf4j@controller公共类IndexController{
private final InstructorService instructorService;
private final StudentService studentService;
private final CarService carService;
private final CarDrivingClassService carDrivingClassService;
public IndexController(InstructorService instructorService, StudentService studentService, CarService carService, CarDrivingClassService carDrivingClassService) {
this.instructorService = instructorService;
this.studentService = studentService;
this.carService = carService;
this.carDrivingClassService = carDrivingClassService;
}
@RequestMapping({"", "/", "/index"})
public String getIndexPage(Model model) {
System.out.println("Getting Index page");
model.addAttribute("cars",carService.findAll());
model.addAttribute("instructors", instructorService.findAll());
model.addAttribute("students", studentService.findAll());
return "index";
}
@GetMapping("/new")
public String newRecipe(Model model){
model.addAttribute("instructor", new InstructorCommand());
return "/form";
}
@PostMapping("instructor")
@Transactional
public String saveOrUpdate(@ModelAttribute InstructorCommand command){
InstructorCommand savedCommand = instructorService.saveInstructorCommand(command);
return "redirect:/";
}
}
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="cars")
public class Car extends BaseEntity{
@Column(name = "name")
private String name;
@OneToOne
private Instructor instructor;
}
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name="instructors")
public class Instructor extends Person{
@OneToMany(mappedBy = "instructor")
public Set<Student> students = new HashSet<>();
@OneToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
private Car car;
}
我正在用这个加载数据
@Component
public class Bootstrap implements CommandLineRunner {
private final CarService carService;
private final StudentService studentService;
private final InstructorService instructorService;
private final CarDrivingClassService carDrivingClassService;
public Bootstrap(CarService carService, StudentService studentService, InstructorService instructorService, CarDrivingClassService carDrivingClassService) {
this.carService = carService;
this.studentService = studentService;
this.instructorService = instructorService;
this.carDrivingClassService = carDrivingClassService;
}
@Override
public void run(String... args) throws Exception {
Date date = new SimpleDateFormat( "yyyyMMdd" ).parse( "19970807" );
Date date2 = new SimpleDateFormat( "yyyyMMdd" ).parse( "20192304" );
Date date3 = new SimpleDateFormat( "yyyyMMdd" ).parse( "20192404" );
Date date4 = new SimpleDateFormat( "yyyyMMdd" ).parse( "20192505" );
/*Creating a student*/
Student student = new Student();
student.setFirstName("Bob");
student.setLastName("Rock");
student.setBirthDate(date);
student.setCity("Miami");
student.setAddress("Lincoln Road");
student.setPostalCode(45300);
Student student2 = new Student();
student2.setFirstName("John");
student2.setLastName("Smith");
student2.setBirthDate(date);
student2.setCity("Miami");
student2.setAddress("Old Cutler Road and Ingraham Highway");
student2.setPostalCode(45100);
/*Class that will save our classes for driving*/
CarDrivingClass savedDrivingClasses;
//Create 20 car driving classes and save them in table CLASSES
for(int i = 0; i<20; i++){
CarDrivingClass tempClass = new CarDrivingClass();
tempClass.setDate(date3);
savedDrivingClasses = carDrivingClassService.save(tempClass);
/*
Fill table STUDENT_CLASSES
* */
student.getClasses().add(savedDrivingClasses);
student2.getClasses().add(savedDrivingClasses);
System.out.println("Saving "+(i+1)+ ". class");
}
/*Instructor one*/
Instructor instructor = new Instructor();
instructor.setFirstName("Dave");
instructor.setLastName("Joe");
instructor.setCity("Miami");
instructor.setAddress("Miami 001");
instructor.setPostalCode(45400);
/*Instructor two*/
Instructor instructor2 = new Instructor();
instructor2.setFirstName("Clark");
instructor2.setLastName("Kent");
instructor2.setCity("LA");
instructor2.setAddress("South Martel Avenue");
instructor2.setPostalCode(95400);
/*Car num one*/
Car audi = new Car();
audi.setName("Audi A7");
audi.setInstructor(instructor);
/*Car num two*/
Car BMW = new Car();
BMW.setName("BMW M4");
BMW.setInstructor(instructor2);
/*Adding car to instructors*/
instructor.setCar(audi);
instructor2.setCar(BMW);
/*Associate student with instructor*/
student.setInstructor(instructor);
student2.setInstructor(instructor);
//Saving into db with services
instructorService.save(instructor);
instructorService.save(instructor2);
studentService.save(student);
studentService.save(student2);
carService.save(audi);
carService.save(BMW);
}
}
这样可以很好地显示数据
<h1>Instructors</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Surname</th>
<th>City</th>
<th>Address</th>
<th>Car</th>
</tr>
</thead>
<tr th:remove="all">
<td>123</td>
<td>Tasty Goodnees 1</td>
<td><a href="#">View</a></td>
</tr>
<tr th:each="instructor : ${instructors}">
<td th:text="${instructor.id}">334</td>
<td th:text="${instructor.firstName}">Tasty Goodnees 3</td>
<td th:text="${instructor.lastName}">Tasty Goodnees 3</td>
<td th:text="${instructor.city}">Tasty Goodnees 3</td>
<td th:text="${instructor.address}">Tasty Goodnees 3</td>
<td th:text="${instructor.getCar().id}">Tasty Goodnees 3</td> <!--getting car id -->
</tr>
</table>
但是当我添加一个新的Instructor时,它在索引表单中显示了一个${Instructor.getcar().id的错误,我可以在表单中添加Instructor而不添加id的输入字段,在index.html Tasty goodnees3中添加这行代码
主要内容:英语教师面试技巧1,英语教师面试技巧2,英语教师面试技巧3,英语教师面试技巧4,英语教师面试技巧5英语教师面试技巧 英语教师面试技巧1 首先就是要在试讲前做好充足的准备,把要讲的内容的相关背景等知识了解到位,并把课的内容和这些背景结合起来,主要是注意如何让背景知识在吸引人的同时把人引导到课本的内容上来。 其次就是出发前的准备,一定要着装合体,不要穿着台前卫,毕竟教师这个职位还是要讲究矜持的。 在见到面试官时要表现的大方,不要太拘禁,也不要太嚣张,给人留下稳重的印象。 试
控制台-单讲师-讲师设置 接口URL {youke-url}/console/index.php?c=instructor&a=setInstructor×tamp=1607677497&access_key=abc&sign=9a85a50874ef4d01ce97665df5820dbeddd4aec0 请求方式 POST Content-Type form-data 请求Query
主要内容:【教师面试注意事项】考生常见问题: 一、知识点太多,不知道十分钟课堂可以讲些什么内容 很多考生在十分钟的课堂里往往存在这样的困惑,我讲一些什么内容呢?真题上的所有知识点都讲完好像时间不够,讲太少似乎又讲不清楚。比如像小学语文《太阳》这一课,这一课课文比较长,考生往往既想把太阳远热大以及和人类的关系这几个知识点段落都分析透,但是往往造成没有重点从而顾此失彼。 二、只讲课程框架,用时过短 一些考生在进行授课的时候,仅仅只
主要内容:教师资格证面试问题1、考中学的教师资格证必须教中学不能教小学吗? 答:专科考的教师资格证教中学和小学都可以。 2、跨省考试存在哪些问题? 答:笔试和面试要求在一个地点考试,大家现在是大二下半学期,还有一年半的时间就毕业了,如果毕业之前能通过面试,在日照参加考试是最方便的,如果毕业之前笔试和面试没有通过,或者笔试通过,面试没有通过,那就需要面试的时候回日照才可以。 3、证书全国通用吗? 答:教师资格证的报考不受户籍限
当你去应聘教师工作时候,是怎么处理教师面试着装问题的呢?以下是出国留学网小编为大家整理的女教师面试着装技巧,欢迎大家阅读,更多精彩内容请关注出国留学网. 1.面试前,女性需要稍微化一些淡妆,显得更有朝气。如果素面朝天地去面试,很容易因为“面黄肌瘦”、“灰头土脸”的本色而丢分。通常,女性至少应该在眉、唇、颊三个部位上稍下工夫。面色红润、朝气蓬勃才显得更有亲和力,更加干练。 2.切忌浓妆艳抹,那不是职
你可以把这个看做一个全栈工程师教程,因为看过“网站开发”部分的几篇文章你基本上就可以开发一个小型的博客网站了,而看过第二部分的几篇你也许对信息检索充满兴趣和信心了,大数据部分还是得花点功夫的,你可以选择放弃,因为比较耗费生命,当然如果你对自己有信心看下去,那么相信你会有收获。