import org.springframework.util.Streamencodingutils import报错

17:12 提问
springMVC上传文件报错
09:13:59,716 ERROR [RequestUtils] Caught error while decoding priorityId.
org.springframework.web.multipart.MultipartException: Could not parse multi nested exception is mons.fileupload.FileUploadBase$IOFileUploadException: Processing o
f multipart/form-data request failed. Stream ended unexpectedly
at org.springframework.monsMultipartResolver.parseRequest(CommonsMultipartResolver.java:163)
at org.springframework.monsMultipartResolver$1.initializeMultipart(CommonsMultipartResolver.java:131)
at org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest.getMultipartParameters(DefaultMultipartHttpServletRequest.java:163)
at org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest.getParameter(DefaultMultipartHttpServletRequest.java:80)
at com.gsol.enigma.web.util.RequestUtils.isLoggedInUniversal(RequestUtils.java:1310)
at com.gsol.enigma.web.util.RequestUtils.isLoggedIn(RequestUtils.java:1253)
at com.gsol.enigma.web.util.RequestUtils.getUser(RequestUtils.java:1058)
at com.gsol.mon.RequestUtil.getUserLocale(RequestUtil.java:64)
at com.gsol.cuckoo.util.interceptor.I18nInterceptor.preHandle(I18nInterceptor.java:63)
at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:130)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:913)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.gsol.cuckoo.filter.LoginFilter.doFilter(LoginFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:115)
at org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:722)
Caused by: mons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at mons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
at mons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115)
at org.springframework.monsMultipartResolver.parseRequest(CommonsMultipartResolver.java:156)
... 42 more
Caused by: mons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
at mons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:1005)
at mons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
at java.io.InputStream.read(InputStream.java:101)
at mons.fileupload.util.Streams.copy(Streams.java:100)
at mons.fileupload.util.Streams.copy(Streams.java:70)
at mons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:347)
... 44 more
按赞数排序
我遇到同样的问题不知道如何解决,请大神指教
222关注|923收录
691关注|560收录
370关注|595收录
其他相似问题
相关参考资料在使用SpringMVC绑定基本类型(如String,Integer等)参数时,应通过@RequestParam注解指定具体的参数名称,否则,当源代码在非debug模式下编译后,运行时会引发HandlerMethodInvocationException异常,这是因为只有在debug模式下编译,其参数名称才存储在编译好的代码中。 譬如下面的代码会引发异常:
Java代码 &
@RequestMapping(value = "/security/login", method = RequestMethod.POST)
public ModelAndView login(@RequestParam String userName, @RequestParam String password,
HttpServletRequest request) {
......................
如果使用Eclipse编译不会在运行时出现异常,这是因为Eclipse默认是采用debug模式编译的,但是如果使用Ant通过javac任务编译的话就会出现异常,除非指定debug=&true&。出现的异常如同:
org.springframework.web.util.NestedServletException: Reque nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659) .......... org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) .......... java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.getRequiredParameterName(HandlerMethodInvoker.java:618) ..........
最好的做法是通过@RequestParam注解指定具体的参数名称,如,上面的代码应该如此编写(注意@RequestParam部分):
Java代码 &
@RequestMapping(value&=&"/security/login",&method&=&RequestMethod.POST)& &&
public&ModelAndView&login(@RequestParam("userName")&String&userName,&&&&@RequestParam("password")&String&password,&&&HttpServletRequest&request)&{&&&&
&&&......................&&
阅读(...) 评论()<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&spring 之脱离容器管理创建的对象进行依赖注入
我们有时候也会遇到一些脱离spring容器创建的类实例,如何把spring容器内的对象注入到这些类实例内呢。
我们可以用org.springframework.beans.factory.config.AutowireCapableBeanFactory.createBean(ClassbeanClass, int
autowireMode, boolean dependencyCheck) 来创建这个脱离容器的对象,该方法返回脱离容器创建的对象,只不过对象的创建交给spring了。
我们可以用(也许这情况比较多,因为此脱离容器创建的对象也许会有其它框架创建)org.springframework.beans.factory.config.AutowireCapableBeanFactory.autowireBean(Object existingBean),把this对象传进来。
代码示例:
* Copyright (C) 2014- now() The
spring4-2015
* /sdcuike
* Licensed under the Apache License, Version 2.0 (the &License&);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &AS IS& BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
package com.doctor.spring4.blog.
import static org.junit.Assert.assertNotN
import static org.junit.Assert.assertN
import java.util.stream.S
import javax.annotation.R
import org.junit.I
import org.junit.R
import org.junit.T
import org.junit.rules.ExpectedE
import org.springframework.beans.factory.annotation.A
import org.springframework.beans.factory.annotation.C
import org.springframework.beans.factory.config.AutowireCapableBeanF
import org.springframework.context.ApplicationC
import org.springframework.context.annotation.AnnotationConfigApplicationC
import org.springframework.context.annotation.C
import org.springframework.context.annotation.EnableLoadTimeW
import org.springframework.context.annotation.EnableLoadTimeWeaving.AspectJW
import org.springframework.context.annotation.aspectj.EnableSpringC
* Wire object dependencies outside a Spring Container-&脱离容器管理创建的对象进行依赖注入
* 脱离容器管理创建的对象进行依赖注入
* @author doctor
* @time 日 上午9:33:54
public class WireObjectDependenciesOutsideSpring {
public ExpectedException expectedException = ExpectedException.none();
* Instantiate the bean and then inject dependencies using AutoWireCapableBeanFactory.autowireBean(instance)
* 看下输出容器内的所有bean,容器内并没有person对象。只是创建返回此对象,并对该对象内的依赖进行注入。
public void test_create_bean_and_inject_dependencies() {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
Person person = (Person) applicationContext.getAutowireCapableBeanFactory().createBean(Person.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
assertNotNull(person.getContext());
Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println);
applicationContext.close();
* Instantiate the bean and then inject dependencies using AutoWireCapableBeanFactory.autowireBean(instance)
public void test_only_inject_dependencies() {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
Person person = new Person();
assertNull(person.getContext());
applicationContext.getAutowireCapableBeanFactory().autowireBean(person);
assertNotNull(person.getContext());
Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println);
applicationContext.close();
@Configuration
static class SpringConfig {
static class Person {
private ApplicationC
public ApplicationContext getContext() {
@Configuration
@EnableSpringConfigured
@EnableLoadTimeWeaving(ectjWeaving = AspectJWeaving.ENABLED)
static class SpringConfig2 {
@Configurable(autowire = Autowire.BY_TYPE, dependencyCheck = true)
static class Person2 {
private ApplicationC
public ApplicationContext getContext() {
上述示例还有一个是用aop实现,不过要开启java选项之类的,网上还有在tomcat下报错的,没仔细学习。
参考:/2012/09/wire-object-dependencies-outside-spring.
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'properties
--> Deployment Assembly -->
Add --> Java Build Path Entries --> Next --> select jar files which are missing --> next --> finish
Application is running successfully...
I have the same issue , and I have resolved it using the steps mentioned above.but no when I have this issue again and
i try the following,
RC(right click on web project) --> properties --> Deployment Assembly --> Add --> Java Build Path Entries --> Next -->
after clicking on next its only a blank window with the options Next and Fnish disabled.What can I do now?
I faced the same problem.
Just removed the server from configuration and added it back after restarting eclipse by adding it to the server runtime environment.
For me the fix was to right click on my webapp module > Maven > Update Project
Solution for Eclipse Luna:
Right Click on maven web project
Click 'Properties'menu
Select 'Deployment Assembly' in left side of the popped window
Click 'Add...' Button in right side of the popped up window
Now appear one more popup window(New Assembly Directivies)
Click 'Java Build path entries'
Click 'Next' Button
Click 'Finish' Button, now atomatically close New Assemby Directivies popup window
Now click 'Apply' Button and Ok Button
Run your webapplication
4,12242655
Actually this is a problem of Tomcat.
Just go to 'lib' folder of your project and copy your all 'Spring' related jars into this. Refresh your project and you are all good to go.
This problem sometime persists because tomcat is unable to locate Spring core classes.
I used IntelliJ IDEA, compilation is successful, but when starting Tomcat, it says:
Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
In the beginning, I thought the JAR was missing, but it was in place.
File & Project Structure & Artifacts, in the Output Layout double click in right panel Available Elements the library named like Maven:..., it will be moved to WEB-INF/lib in the left pane.
Accept and restart Tomcat.
3,67882237
Using the "Update project configuartion" messed up the build path of the project.
Fix: Open the "configure build path..." menu (right click on the project) and fix the Included/Excluded options for each source folder.
That worked for me.
In many case It is java facet problem ,jdk or jre or jsp
version is difference than maven project face.
The actual solution for me was to install the "m2e-wtp - Maven integration for WTP". The solution of Marcelo is not neccessary in that case.
if nothing from above works, remove the .class
from the listener class
&ltlistener&gt
&ltlistener-class&gt
org.springframework.web.context.ContextLoaderListener.class
&lt/listener-class&gt
&lt/listener&gt
3,69051636
I also had the same error. I had not added the below dependency in my POM file.
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-web&/artifactId&
&version&4.1.7.RELEASE&/version&
&/dependency&
But My porject used to run even before I had added this dependency. But at one point it stopped and started giving the same above error.
If any one couldn't solve this error they can also solve by this
This works for me ..
Right Click on maven web project
Click 'Properties'menu
Select 'Deployment Assembly' in left side of the popped window
Click 'Add...' Button in right side of the popped up window
Now appear one more popup window(New Assembly Directivies)
Click 'Java Build path entries'
Click 'Next' Button
Click 'Finish' Button, now atomatically close New Assemby Directivies popup window
Now click 'Apply' Button and Ok Button
Run your webapplication
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 util utils区别 的文章

 

随机推荐