当我阅读Spring PetClinic示例应用程序时,我发现他们总是将添加和修改功能放入单个 JSP 文件中,并且他们使用${owner['new']}
表达式来自定义当前页面上的元素,例如标签的“新所有者”或“所有者”。
[]
在 JSP (Spring) 环境中还有其他操作符的用法吗?
控制器文件有以下片段:
@RequestMapping(value = "/owners/new", method = RequestMethod.GET)
public String initCreationForm(Map<String, Object> model) {
Owner owner = new Owner();
model.put("owner", owner);
return "owners/createOrUpdateOwnerForm";
}
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET)
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
Owner owner = this.clinicService.findOwnerById(ownerId);
model.addAttribute(owner);
return "owners/createOrUpdateOwnerForm";
}
JSP 文件具有以下片段:
<h2>
<c:if test="${owner['new']}">New </c:if> Owner
</h2>