我想在单击房间名称时显示房间详细信息.. 但我遇到了一个问题,我不知道为什么。我使用 Spring MVC、Spring Boot、Spring Data 和 Thymeleaf
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'name' cannot be found on object of type 'java.util.Optional' - maybe not public or not valid?
Run Code Online (Sandbox Code Playgroud)
我认为问题是关于 Optional in Service 当我使用 Spring Data findById() 这是我的代码
房间模型
@Entity
@Table(name ="room")
public class Room implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID_room", nullable = false)
private String id;
@Column(name = "name_room", nullable = false)
private String name;
@Column(name = "Description") …Run Code Online (Sandbox Code Playgroud) 我使用 mat-autocomplete 来过滤我的数据。一切正常,但我想要一个下拉箭头来显示输入中的所有选项。在 md-autocomplete 中,我们可以使用dropdown-arrow="true"但在 mat-autocomplete 中不支持它。那么如何在 mat-autocomplete 中添加下拉箭头呢?这是我的component.ts
<form class="example-form">
<mat-form-field class="example-full-width">
<input type="text" aria-label="Number" matInput
[formControl]="myControl" [matAutocomplete]="auto4"
[hidden]="loadWithFilters&&loadWithFilters.field==='IP'">
<mat-autocomplete #auto4="matAutocomplete" dropdown-arrow="true"
(optionSelected)="onFilterOptionSelected($event,'IP')" >
<mat-option *ngFor="let option of filteredIP | async"
[value]="option.key">
{{option.value}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</form>
Run Code Online (Sandbox Code Playgroud) 首先我要抱歉,因为我的英语不好。我正在学习 Spring Framework,我正在使用 Spring Boot、Spring Data、Spring MVC 制作一个简单的应用程序。
现在我有一个错误,但我不知道为什么。
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 你的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的 'describe='Education', name_room='Boston', id_status='2' where id_room='1'' 附近使用正确的语法
这是我的代码:
Room Model
@Entity
@Table(name ="room")
public class Room implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID_room", nullable = false)
private String id;
@Column(name = "name_room", nullable = false)
private String name;
@Column(name = "Describe")
private String describe;
@Column(name = "ID_status")
private String status;
public Room() {
super(); …Run Code Online (Sandbox Code Playgroud)