【发布时间】:2016-09-22 04:57:10
【问题描述】:
我有一个 Spring / Thymeleaf 应用程序
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'projectName' cannot be found on null
但是,页面看起来正常。所有变量都与数据一起呈现。我只是担心每个请求都会引发异常。
这里是控制器:
@Controller
@RequestMapping("/download")
public class AppDownloaderController {
@Autowired
InstallLinkJoinedService installLinkJoinedService;
@RequestMapping(value = "/link/{installLink}", method = RequestMethod.GET)
public String getInstallLink(Model model, @PathVariable("installLink") String installLink) {
InstallLinkJoined installLinkJoined = installLinkJoinedService.getInstallLinkWithID(installLink);
if (installLinkJoined != null) {
model.addAttribute("install", installLinkJoined);
}
return "download";
}
}
有问题的 html 的 sn-p:
<h3 class="achievement-heading text-primary" th:text="${install.projectName}"></h3>
该字段是 InstallLinkJoined 对象的一部分:
@Column(nullable = false)
private String projectName;
我对所有领域都有 getter 和 setter。
如果我注释掉有问题的行,我只会在下一个变量处得到一个异常。
而且,如上所述,页面中的所有数据都显示出来了,很明显模型对象不为空......
我错过了什么?
【问题讨论】:
标签: java sql spring jdbc thymeleaf