作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人知道如何在 JSP 上使用 Optional 对象吗?
我有一个类:
@Entity
@Table(name = "projects")
public class Project {
@Expose
@ManyToOne
@JoinColumn(name = "customer_id")
private Customer endCustomer;
....
public Optional<Customer> getEndCustomer() {
return Optional.ofNullable(endCustomer);
}
public void setEndCustomer(Customer endCustomer) {
this.endCustomer = endCustomer;
}
....
}
我有 jsp:
<td>
<form:select class="form-control" id="endCustomer" path="endCustomer.id" tabindex="4">
<form:options items="${endCustomers}" itemValue="id" itemLabel="name"/>
</form:select>
</td>
由于显而易见的原因,这部分不起作用:path="endCustomer.id"
有解决办法吗?谢谢!
最佳答案
尝试这样的事情
<td>
<form:select class="form-control" id="endCustomer" path="${endCustomer.get().id}" tabindex="4">
<form:options items="${endCustomers}" itemValue="id" itemLabel="name"/>
</form:select>
</td>
关于Java 8 可选项和 JSP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45996695/
在观看有关 LLDB 调试器的 Apple 视频时,我发现了一些我无法找到解释的内容;他写道: var optional: String? = nil; //This is ok, a common
我是一名优秀的程序员,十分优秀!