【发布时间】:2017-04-27 11:04:14
【问题描述】:
我有一些代码可以访问对象属性 datacenter.getId(),该属性是 Long 类型。
@编辑
问题出在另一段代码中。 跟随新的代码。
<tbody>
@for(datacenter <- datacenterList){
@for(rack <- datacenter.getRacks()){
@for(host <- rack.getHosts()){
<tr>
<td>
@host.getId()
</td>
<td>
@host.getName()
</td>
<td>
@host.getDescription()
</td>
<td>
@rack.getName()
</td>
<td>
@host.getHeightInRackUnits()
</td>
<td>
@host.getEstimatedSizeInTB()
</td>
<td>
<a id = "delete-host" class="delete" href="@routes.InfrastructureController.deleteHost(host.getId())" >
<i class="fa fa-trash-o" style="font-size: 1.3em;"style="font-size: 1.3em;" title="Excluir" data-toggle="modal" data-target="#confirm-modal" data-placement="top" rel="tooltip"></i></a>
</td>
</tr>
}
}
}
</tbody>
遵循路线:
DELETE /hosts/:id controllers.InfrastructureController.deleteHost(id:Long)
控制器方法:
public Result deleteHost(Long id) {
return null;
}
我收到以下错误:
[error] 2016-12-12 11:53:13 -0300 admin - Um erro aconteceu no servidor
java.lang.NullPointerException: null
at scala.Predef$.Long2long(Predef.scala:358)
at views.html.infrastructure.infrastructure_Scope0$infrastructure$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(infrastructure.template.scala:204)
at views.html.infrastructure.infrastructure_Scope0$infrastructure$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(infrastructure.template.scala:180)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:742)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
问题已解决
我已经找到了错误。 该对象的 id 参数为空。 很抱歉,感谢您试图帮助我。
【问题讨论】:
-
需要完整的堆栈跟踪
-
空指针异常发生的行号在哪里?用什么方法?粘贴完整的堆栈跟踪?
-
完整的堆栈跟踪已更新@pamu
-
@pamu 错误在另一段代码中。
标签: java scala playframework nullpointerexception playframework-2.0