日期:2014-05-20  浏览次数:20777 次

struts2 与 FckEditor整合上传文件的问题!!
做到了一半,要用fckeditor,用的是struts2.1.8做的. 整合后,FCKEDITOR上传文件有问题,Console台提示:
Java code
2010-2-7 20:56:01 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet ConnectorServlet threw exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at net.fckeditor.connector.Dispatcher.doPost(Dispatcher.java:255)
    at net.fckeditor.connector.ConnectorServlet.doPost(ConnectorServlet.java:128)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    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 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
    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:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)


看错误好像是fckEditor没有得到request....
在网上查过答案,说是因为struts2的filter拦截了fckeditor的servlet,然后是什么request被struts2修改了什么的.没看懂...
原本在web.xml文件中配置的struts2的filter的url-pattern是/*,如果要改动这里的话,要修改的地方很多,会很麻烦...

试着在struts.xml文件里面添加一个指向FCKEDITOR的servlet的action配置,但是没有用.  

想问一下,如果不改struts2的url-pattern,可以解决fckeditor上传文件的问题吗?

PS:后来又想过自己再写一个Filter,在struts2的filter之前拦截,然后直接调用fckeditor的servlet...但是不知道具体要怎么写...

先谢谢了...

------解决方案--------------------
探讨
不是这原因啊..我是用fckeditor来上传的,就一张小图片...肯定不是上传文件大小的问题..

不过,还是谢谢你哈..

------解决方案--------------------
应该是fck取数据的前就被strut2拦截到 struts.multipart.parser=jakarta JakartaMultiPartRequest
里面处理去了,然后清空request的文件流对象。
轮到fck的去读的时候已经读不到啦。也就是items为[],FileItem uplFile = items.get(0);这时就会抛出
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 

具体原因我也在找,找到后联系你。