在与请求 object.why 关联的空对象上调用方法时,JSTL 中没有 NullPointerException?

No NullPointerException in JSTL when calling methods on null object associated with request object.why?

昨天我出现在一个采访中。面试官给我看这段代码并问-

<c:when test='${hobby.equals("hobby1")}'>

为什么没有空指针,而hobby的值为null

代码为-

In Sevlet class-

request.setAttribute("hobby", null);
request.getRequestDispatcher("display.jsp").forward(request, response);

In display.jsp-

<c:when test='${hobby.equals("hobby1")}'>

JSTL 几乎总是抑制 NullPointerExceptions。有一个简短的讨论here and more detail can be found in section 3.6 of the JSTL spec