Struts,Spring,Hibernate中容易出错的基本问题
?
??10.报错: org.apache.jasper.JasperException: $Proxy3 cannot be cast to com.xj.service.impl.RoleService java.lang.ClassCastException: $Proxy3 cannot be cast to com.xj.service.impl.RoleService 原因:很明显又是一个代理时候,强转错误: ServletContext context = servlet.getServletContext(); ApplicationContext app = (ApplicationContext) context.getAttribute ?(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); IDeptService ds = (DeptService) app.getBean("deptservice"); this.depList = ds.selectAllDeps(); 就是这段示例代码中的 IDeptService ds = (DeptService) app.getBean ("deptservice");出错了 不能直接强转成接口的实现类,一定要转成接口. IDeptService ds = (IDeptService) app.getBean("deptservice");??
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
1 楼 avanry 2008-09-05 写的不错,最近正用ssh呢
支持一个,希望继续更新