NutzCN Logo
问答 多张图片上传报这个错误,帮我看下谢谢
发布于 2786天前 作者 qq_418196a2 1474 次浏览 复制 上一个帖子 下一个帖子
标签:
java.lang.IllegalArgumentException: Method miss match: expect public java.lang.Object net.wendal.nutzbook.module.UserModule.headImg(javax.servlet.http.HttpSession,org.nutz.mvc.upload.TempFile,org.nutz.mvc.impl.AdaptorErrorContext,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException but public java.lang.Object net.wendal.nutzbook.module.ContributeModule.contributeAdd(org.nutz.mvc.upload.TempFile[],org.nutz.mvc.impl.AdaptorErrorContext,java.lang.String,java.lang.String,javax.servlet.http.HttpSession). using Ioc? set singleton=false, pls
	at org.nutz.mvc.upload.UploadAdaptor.adapt(UploadAdaptor.java:118)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:119)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:179)
	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.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
@At
	@AdaptBy(type=UploadAdaptor.class,args={"ioc:upload"})
	public Object contributeAdd(@Param("file") TempFile[] tmp,AdaptorErrorContext err,@Param("title") String title,@Param("content")String content,HttpSession session){
		int uid=(int)session.getAttribute("me");
/*		String filepatname[] = null;*/
		for (TempFile tempFile : tmp) {
			System.out.println(">>>>>>>>>图片路径【IMG-INFO】:"+tempFile.getFile().getPath());
			if(err!=null){
				log.debug(err.getAdaptorErr());
				return false;
			}
			File file=tempFile.getFile();
			String uuid=UUID.randomUUID().toString().replaceAll("-","");
			String dest=webPath(uuid)+"."+Files.getSuffixName(file).toLowerCase();
			String smallPath=webPath(uuid)+"_128x128."+Files.getSuffix(file).toLowerCase();
			try {
				Images.zoomScale(file, new File(smallPath), 128, 128, Color.BLACK);//得到图片大小
				file.renameTo(new File(dest));
			} catch (Throwable e) {
				log.info(e);
				return "";
			}
			filepathnames[0]="/upload/images/" + uuid + "."+ Files.getSuffixName(file).toLowerCase();//图片的绝对路径
			System.out.println("图片:>>>"+filepathnames);
		}
		boolean bo=new ContributeService().contributeAdd(uid, title, content.trim(),filepathnames[0],filepathnames[1],filepathnames[2],dao);
		return CommonJson.commonJosnFormat(true, bo);
	}
9 回复

找了好久,我不知道是哪里的错误

upload.js贴出来

$.ajaxFileUpload({
			url:base+'/contribute/contributeAdd',
			secureuri:false,//是否需要安全协议,一般为false
			fileElementId:['select_file1','select_file2','select_file3'],
			data:{'title':type,
				'content':content,
			},
			dataType:'json',
			type:'post',
			success:function(data){
				if(data){
					document.getElementById("content").value="";
					layer.open({
						    content: '投稿成功,要看一下吗?'
						    ,btn: ['看一看', '继续投稿']
						    ,yes: function(index){
						      window.location.href='../userinfo/page?id=me';
						      layer.close(index);
						    }
						  });
					addIntgeral();
				}else{
					alert("抱歉,发表失败!");
				}
			},
			error:function(){
				layer.open({
					content:'抱歉,服务器请求失败,请稍后再重试。',
					skin:'msg',
					time:2,
				});
			}
		});
	});

谢谢 帮我看下

var ioc = {
		upload : {
			type : "org.nutz.mvc.upload.UploadAdaptor",
			args : [{refer : "uploadCtx"}]
		},
		uploadCtx : {
			type : "org.nutz.mvc.upload.UploadingContext",
			args : [{refer: "filePool"}],
			fields : {
				ignoreNull : true,
				maxFileSize : 10240000,
				nameFilter : ".+(jpg|png|gif|GIF)"
			}
		},
		filePool : {
			type : "net.wendal.nutzbook.upload.WebFilePool",
			args : ["/upload/", 5000]
		}
};

ioc的js配置文件,不是前端js

改成

		upload : {
			type : "org.nutz.mvc.upload.UploadAdaptor",
     singleton:false,  //加这行
			args : [{refer : "uploadCtx"}]
		},

@qq_418196a2 请问下,你前台代码怎么写上传多个图片

添加回复
请先登陆
回到顶部