Spring文件上传出错:java.lang.ClassCastException: org.apache.catalina.connector.Request

java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

蕃薯耀 2016年5月6日 15:44:39 星期五

http://fanshuyao.iteye.com/

 

java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest

 

一、详细的错误信息(解决方法在下面):

 

java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest
	at com.lqy.spring.iwx.controller.BaseController.getFileEntityAfterUpoad(BaseController.java:429)
	at com.lqy.spring.iwx.controller.backend.weixin.WxMaterialController.uploadMaterial(WxMaterialController.java:192)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:775)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:867)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

 

 

二、解决方法:在SpringMvc.xml文件中增加Spring文件上传的解析器,如下

 

<!-- 上传文件拦截,设置最大上传文件大小 10M=10*1024*1024(B)=10485760 bytes -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="10485760" />
		<!-- resolveLazily属性启用是为了推迟文件解析,以便在Action 中捕获文件大小异常 -->
		<property name="resolveLazily" value="true" />
		<property name="defaultEncoding" value="UTF-8" />
	</bean>

 

 

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

蕃薯耀 2016年5月6日 15:44:39 星期五

http://fanshuyao.iteye.com/

引用: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long 引用: 在执行时出现类型转换错误:java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long 引用: org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long 问题描述中提到的错误是java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer,而不是java.lang.Long cannot be cast to java.lang.Integer。这个错误可能发生在数据库查询中,在执行查询时,将java.lang.Long类型错误地转换为java.lang.Integer类型。 要解决这个问题,可以考虑以下几个步骤: 1. 检查数据库表中相应的列的数据类型是否为java.lang.Integer类型,而不是java.lang.Long类型。如果列的数据类型为java.lang.Long,请将其更改为java.lang.Integer。 2. 检查数据库连接是否正确,确保数据库连接的配置与实际情况相符。 3. 检查MyBatis的映射文件中的查询语句,确保查询结果被正确地映射为java.lang.Integer类型。 4. 如果以上步骤都没有解决问题,可以考虑重新编译和构建项目,以确保所有依赖项和配置文件都正确地加载和使用。 需要注意的是,这只是一种可能的解决方法,具体的解决方案可能根据实际情况而异。<span class=&quot;em&quot;>1</span><span class=&quot;em&quot;>2</span><span class=&quot;em&quot;>3</span> #### 引用[.reference_title] - *1* *3* [java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long](https://blog.csdn.net/qq_36785719/article/details/90201942)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] - *2* [关于hibernate执行select count( *) 出现java.lang.ClassCastException问题](https://blog.csdn.net/cekong0704/article/details/9944731)[target=&quot;_blank&quot; data-report-click={&quot;spm&quot;:&quot;1018.2226.3001.9630&quot;,&quot;extra&quot;:{&quot;utm_source&quot;:&quot;vip_chatgpt_common_search_pc_result&quot;,&quot;utm_medium&quot;:&quot;distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2&quot;}}] [.reference_item style=&quot;max-width: 50%&quot;] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值