【发布时间】:2013-08-09 06:46:01
【问题描述】:
long orgId = (Long)request.getSession().getAttribute("orgId");
我无法转换从request.getSession().getAttribute("orgId") 获得的对象
长变量
所以我需要将它转换为长。 无论如何都可以提供帮助。
【问题讨论】:
-
long orgId = (Long)(request.getSession().getAttribute("orgId")).longValue();
-
您确定
session#getAttribute("orgId")中存储的数据是Long类型还是String格式? -
我能预见的唯一问题是你没有设置
orgId属性,它返回null所以你的代码失败了。当然,如果您编辑您的问题并发布错误的堆栈跟踪,而不是仅仅说 I am not able to foo the bar,我们可以给您一个正确的答案。
标签: java type-conversion