毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

uploadify结合struts2的时候文件取值出错

更新时间:2012-12-3:  来源:毕业论文

debug的时候进了action,可是在setUpload方法之前就报错了,错误信息在下面,jsp里面:
<s:form action="/theme/themeManage!insertTheme.action" id="insertThemeForm" method="post" theme="simple" enctype="multipart/form-data">
<input type="file" id="upload" name="upload" />
</s:form>

js里面:

JavaScript code
 $(function() {           $("#upload").uploadify({             'swf' : '../js/uploadify/uploadify.swf',             'uploader' : '/nbtback/theme/ajaxTheme!insert.action',             'cancelImg' : '../js/uploadify/uploadify-cancel.png',             'folder' : 'uploads',             'queueID' : 'fileQueue',             'auto' : true,             'width' : 130,             'height' : 30,             'fileObjName' : 'upload',             'multi' : true,//这里是指定能否上传多个,我改下             'simUploadLimit' : 2,//一次可以选择多少个文件              'buttonText' : '浏览',//按钮文字             method : 'post',             onUploadError : function(file, code, msg, errStr) {                 alert(errStr);             },             onUploadSuccess : function() {               }         });


action里面用来取值的文件相关的三个参数:
private File upload;
private String uploadFileName;// 文件的名称含有后缀
private String uploadContentType;// 文件的类型
get、set方法省略

报的错误如下:Cannot create type class java.io.File from value Submit Query - [unknown location]
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:152)
at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:146)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:334)
at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:39)
at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1067)
at ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:1084)
at ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:1110)
at ognl.OgnlRuntime.getAppropriateMethod(OgnlRuntime.java:1196)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1210)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1481)
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318)
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:77)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209)
at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:173)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:160)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:151)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:203)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:320)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.tc.blacktea.auth.action.AuthInterceptor.intercept(AuthInterceptor.java:25)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
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:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

话说这到底是为甚啊?

报错很明显:报的错误如下:Cannot create type class java.io.File from value Submit Query - [unknown location]

就是指:没有读取到你的文件路径,所有问题出在你的文件路径读取上。
flash上传都有session问题,flash默认会重新生成一个session提交到服务器,与后台的session不一致了,所以你要传递sessionid过去,jsessionid=<%=session.getId()%>加上这个参数就可以了。
tomcat可以这么解决,其他服务器未测试~!

几点你修改一下试试看
1.js中,去掉folder那个参数
2.html中去掉form,直接放一个input就好。
3.action中get set方法都有了吗,对吗?
4.注意一下这个异常
-[WARN] Error setting expression 'Upload' with value '[Ljava.lang.String;@4c0a7e2e'
ognl.MethodFailedException: Method "setUpload" failed for object com.tc.blacktea.sys.action.ThemeAction@67e4596 [java.lang.NoSuchMethodException: com.tc.blacktea.sys.action.ThemeAction.setUpload([Ljava.lang.String;)]
Upload是什么?

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。