当前位置: 代码迷 >> Java Web开发 >> 关于java.lang.Integer cannot be cast to java.lang.Long的 疑问,该怎么处理
  详细解决方案

关于java.lang.Integer cannot be cast to java.lang.Long的 疑问,该怎么处理

热度:5792   发布时间:2013-02-25 21:22:55.0
关于java.lang.Integer cannot be cast to java.lang.Long的 疑问
大家好,我是个J2EE初学者,我写了这么一段代码,但是出现了,类型转换不合法的问题。但是我不清楚为什么会出现这样的错误。希望大家能够帮我看看。谢谢大家了。

public class ScjLogic extends KmapBaseLogic {
// 注入scjdao 
private ScjDao scjdao;

public ScjDao getScjdao() {
return scjdao;
}

public void setScjdao(ScjDao scjdao) {
this.scjdao = scjdao;
}

/**
* 初始化技能点页面
* @return
*/
public String initJndScj(){
this.getHttpRequest().getSession().setAttribute("empId",1586);

//String sessionLL = (String)session.getAttribute("sessionLL") ;
Long empId = (Long)this.getHttpRequest().getSession().getAttribute("empId");

List JndName = new ArrayList();

List JndList = scjdao.getJnd(empId);

getHttpRequest().getSession().setAttribute("JndList", JndList);

int listlength = JndList.size();
for(int i=0;i<listlength;i++){
Technology technology = (Technology)JndList.get(i);
List techPathName = scjdao.getJndLjName(technology.getId());

JndName.add(techPathName);
}
getHttpRequest().getSession().setAttribute("JndName",JndName);
return "initjndscjsuccess";
}

错误提示是:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at com.thunisoft.jndscj.business.service.ScjLogic.initJndScj(ScjLogic.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.thunisoft.summer.web.action.MemoryAction.execute(MemoryAction.java:103)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.thunisoft.summer.security.access.filter.ACFilter.doFilter(ACFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.thunisoft.summer.web.filter.CharsetFilter.doFilter(CharsetFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
  相关解决方案