我已经检查过session.parent_id和session.id_of_project在gsp的下面代码中不为空
<g:if test="$session.parent_id">
<g:set var="permission" value="${Project_permission.findAllById_of_projectAndParent_id(session.id_of_project, session.parent_id)}"/>
<g:each var="emp" in="${permission}">
<g:set var="employee2" value="${Employee.findById(emp.id_of_employee)}"/>
<li class="parent_li">
<span class="badge red" title="Collapse this branch">
<i class="fa fa-minus-sign">
</i> Child
</span>
<a href="">Anyhing can go here!
</a>
</li>
</g:each>
</g:if>
但它继续显示:
错误500:内部服务器错误 显示java.lang.NullPointerException 信息 无法在null对象上调用方法findAllById_of_projectAndParent_id()
答案 0 :(得分:2)
尝试在gsp的开头添加:
<%@ page import="package.Project_permission" %>
<%@ page import="package.Employee" %>
将package
替换为实际包裹。
无论如何,如果你要去findById
,最好做Employee.get(id)