ajaxfileupload.js与struts2文件上传文件报错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ajaxfileupload.js与struts2文件上传文件报错相关的知识,希望对你有一定的参考价值。
There is no Action mapped for namespace / and action name ??????????????????. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
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:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1805)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
可以从2个方向去找问题:
1struts.xml配置文件
2请求form的action、namespace属性
主要方法:
1(一般可以解决)比较form的action、namespace属性与struts.xml中对应的action的name、namespace配置是否一致
2很细节的地方:如struts.xml根本未加载、配置文件格式有问题等等。。。这些很难找的追问
现在是当我重启下tomcat,又可以上传成功。当上传几次过后,再次上传就失败。就报这个错!!
追答建议重新部署一下项目,或者重新写一遍(可以自己写,也可以参照案例)。
追问重新部署也是这种问题!!
追答没有错误提示,很难下手
参考技术A 表单属性namespace的值要与action配置文件中的package中的namespace要一致追问现在是当我重启下tomcat,又可以上传成功。当上传几次过后,再次上传就失败。就报这个错!!
追答我之前也碰到过着种问题,后来重新写了一遍,在struts配置文件中加上了input元素,也是ajax文件上传
追问能详细说下吗??
ajaxfileupload.js异步提交图片
碰到问题的解决方法:http://blog.yadgen.com/?p=970
<script type="text/javascript" src="_LIB_/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="_JS_/jquery.ajaxfileupload.js"></script>
$(function () { 2 //照片异步上传 3 $(‘#inputImage‘).on("change",function () { //此处用了change事件,当选择好图片打开,关闭窗口时触发此事件 4 $.ajaxFileUpload({ 5 url: "<{:url(‘index/Article/imgUpload‘)}>", //处理图片的脚本路径 6 type: ‘post‘, //提交的方式 7 secureuri: false, //是否启用安全提交 8 fileElementId: ‘inputImage‘, //file控件ID 9 dataType: ‘json‘, //服务器返回的数据类型 10 success: function (data, status) { //提交成功后自动执行的处理函数 11 $(".artImg").attr("src",data); 12 $("#imgYz").val(data); 13 }, 14 error:function(e){ 15 alert(1); 16 } 17 }) 18 }); 19 });
<p><label><span>封面图片:<input type="file" name = "artImg" id="inputImage"></span></label></p> <img src="" style="width:200px;" class="artImg img-rounded"> <input style="display:none;" name="art_img" id="imgYz" type="text" value="">
以上是关于ajaxfileupload.js与struts2文件上传文件报错的主要内容,如果未能解决你的问题,请参考以下文章
jQuery插件ajaxfileupload.js源码与使用