问题描述
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Listcn.com.kxrj.background.action.member.QuestionTypeAction.findAll(QuestionTypeAction.java:70)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)cn.com.kxrj.servlet.interceptor.AuthorityInterceptor.intercept(AuthorityInterceptor.java:68)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
解决方案
引用java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List这是个类型转换失败的错误信息。Map是用key value 键值对储存的 list是下标方式可能你在从Map中拿出数据放到list中的时候类型没有放对
解决方案二:
把这段代码打上来看看哈cn.com.kxrj.background.action.member.QuestionTypeAction.findAll(QuestionTypeAction.java:70) QuestionTypeAction.java:70我猜可能是从map里面取出来值你强制转换为List了,但实际它是String型的~放到map时可能有问题
解决方案三:
map不能直接转换成list应该用map的值,(用.values()获得)---->转换成collection再用list的add方法,遍历添加collection元素!
解决方案四:
有可能你的list是泛型的吧?
解决方案五:
引用java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List 看错误时强制类型转化失败,代码贴出来看看