我在生成的 GSP 页面中看到了这一点。什么是? mean?
<g:textField name="name" value="${phoneInstance?.name}" />
它就是“安全导航操作符”,它是 Groovy 的一项功能,可以简洁地避免空指针异常。看http://docs.groovy-lang.org/latest/html/documentation/index.html#_safe_navigation_operator http://docs.groovy-lang.org/latest/html/documentation/index.html#_safe_navigation_operator
在这种情况下,如果phoneInstance
为空,那么它不会尝试获取name
属性并导致 NPE - 它只是将字段标记的值设置为 null。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)