NutzCN Logo
问答 nutz 1.r.59 上传大文件执行了两次
发布于 2900天前 作者 qq_c874e4a6 2040 次浏览 复制 上一个帖子 下一个帖子

nutz 1.r.59 上传文件方法

@At
	@Filters(@By(type = RightFilter.class, args = { "ioc:rightFilter" }))
	@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
	public Msg uploadFile(@Param("filedata") TempFile[] files) {

	}

在RightFilter判断了session超时

	CorpMobile corpMobile =  (CorpMobile)request.getSession().getAttribute(Keys.SESSION_KEY_CORPMOBILE);
				if (corpMobile == null)
					throw new ServiceException(Keys.MSG_CODE);

现在执行上传小文件时没问题,因为判断了session,所以直接返回异常。

2016-12-08 08:23:57,560 [http-bio-8080-exec-3] WARN  [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
	at com.f139.data.filter.RightFilter.match(RightFilter.java:47)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:198)
	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:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)




现在上传大文件时,通过日志查看uploadFile执行了两次,页面重定向了。

2016-12-08 08:25:31,112 [http-bio-8080-exec-7] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 08:25:31,112 [http-bio-8080-exec-7] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 08:25:31,112 [http-bio-8080-exec-7] WARN  [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
	at com.f139.data.filter.RightFilter.match(RightFilter.java:47)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:198)
	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:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
2016-12-08 08:25:31,153 [http-bio-8080-exec-8] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 08:25:31,153 [http-bio-8080-exec-8] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 08:25:31,153 [http-bio-8080-exec-8] WARN  [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
	at com.f139.data.filter.RightFilter.match(RightFilter.java:47)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:198)
	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:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

25 回复

是浏览器的原因吧

@wendal 测试了chrome\firefox都存在这个问题。

@qq_c874e4a6 看chrome的开发者工具里面的网络请求,看看是不是发起了两次

@wendal 网络请求一次的。

用了什么上传插件??然后它用ajax发一次,flash又发了一次?

可以debug一下NutFilter的doFilter方法,从而分辨出到底是nutz内执行两次,还是浏览器请求了2次

@wendal

没有用上传插件,就普通的表单提交,上传小文件没问题的。

在NutFilter的doFilter方法,加了断点,执了两次。

所以,还是浏览器/页面的问题, 贴页面看看

@wendal

只针对上传大文件存在该问题

上传页面:



Filename:





入口:
@At
@Filters(@By(type = RightFilter.class, args = { "ioc:rightFilter" }))
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
public Msg uploadFile(@Param("filedata") TempFile[] files) {

}

过滤器:

@Override
public View match(ActionContext actionContext) {
HttpServletRequest request = actionContext.getRequest();
Method method = actionContext.getMethod();

    CorpMobile corpMobile = (CorpMobile) request.getSession().getAttribute(Keys.SESSION_KEY_CORPMOBILE);
    if (corpMobile == null)
       throw new ServiceException(Keys.MSG_CODE);
    return null;
}

日志:

2016-12-08 09:16:45,265 [http-bio-8080-exec-3] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 09:16:45,267 [http-bio-8080-exec-3] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 09:16:45,274 [http-bio-8080-exec-3] WARN [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
at com.f139.data.filter.RightFilter.match(RightFilter.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
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:198)
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:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
2016-12-08 09:16:45,677 [http-bio-8080-exec-4] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 09:16:45,678 [http-bio-8080-exec-4] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 09:16:45,678 [http-bio-8080-exec-4] WARN [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
at com.f139.data.filter.RightFilter.match(RightFilter.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
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:198)
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:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

回复框上方有插入代码的按钮.

@wendal

上传页面:

<html>
<body>
<form action="http://127.0.0.1:8080/laohufeigang/business/uploadFile.do" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="filedata" id="filedata" />  
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html> 
入口地址:

@At
	@Filters(@By(type = RightFilter.class, args = { "ioc:rightFilter" }))
	@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
	public Msg uploadFile(@Param("filedata") TempFile[] files) {
		System.out.print("upload");
		return null;
	}
日志:

2016-12-08 09:16:45,265 [http-bio-8080-exec-3] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 09:16:45,267 [http-bio-8080-exec-3] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 09:16:45,274 [http-bio-8080-exec-3] WARN  [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
	at com.f139.data.filter.RightFilter.match(RightFilter.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:198)
	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:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
2016-12-08 09:16:45,677 [http-bio-8080-exec-4] DEBUG [org.nutz.mvc.impl.UrlMappingImpl] - Found mapping for [POST] path=/business/uploadFile : Business.uploadFile(Business.java:606)
2016-12-08 09:16:45,678 [http-bio-8080-exec-4] DEBUG [org.nutz.ioc.impl.NutIoc] - Get 'business'<class com.f139.data.module.business.Business>
2016-12-08 09:16:45,678 [http-bio-8080-exec-4] WARN  [org.nutz.mvc.impl.processor.FailProcessor] - Error@/business/uploadFile :
com.f139.data.exception.ServiceException
	at com.f139.data.filter.RightFilter.match(RightFilter.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:50)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:198)
	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:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

@wendal

过滤器:

@Override
	public View match(ActionContext actionContext) {
		HttpServletRequest request = actionContext.getRequest();
		Method method = actionContext.getMethod();

		CorpMobile corpMobile = (CorpMobile) request.getSession().getAttribute(Keys.SESSION_KEY_CORPMOBILE);
		if (corpMobile == null)
			throw new ServiceException(Keys.MSG_CODE);
		return null;
	}

如果去掉这个过滤器的话, 会怎样??

@wendal

如果去掉这个过滤器的话,没问题,可以上传成功。

也许是@Fail的问题? 因为过滤器抛出了异常,然后走@Fail了

@wendal

@Fail("json")
@Ok("json")

把这个入口方法加上 @Fail("void") 看看会怎样

@wendal

@At
@Filters(@By(type = RightFilter.class, args = { "ioc:rightFilter" }))
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
@Fail("void")

还是一样的有问题.

看来跟异常没有关系,所以呢,只剩下request.getSession这个可疑点了

改成request.getSession(false),且判断一下是否为null吧

@wendal

修改了过滤器,问题还是存在。

@Override
	public View match(ActionContext actionContext) {
		HttpServletRequest request = actionContext.getRequest();
		Method method = actionContext.getMethod();

		HttpSession session = request.getSession(false);
		if (session == null) 
			throw new ServiceException(Keys.MSG_CODE);
		

		CorpMobile corpMobile = (CorpMobile) session.getAttribute(Keys.SESSION_KEY_CORPMOBILE);
		if (corpMobile == null)
			throw new ServiceException(Keys.MSG_CODE);

		return null;
	}

好吧, 那只能一行行注释掉,看看哪里的问题了

谢谢 @wendal,
请问下个版本能修复该问题吗?

@qq_c874e4a6 修复这个问题? 我还看不出是nutz的问题呢

你做的拦截器注释掉就没问题,要根据这线索查下去

拦截器也就判断了一个session,应该不是这里的问题

@Override
	public View match(ActionContext actionContext) {
		HttpServletRequest request = actionContext.getRequest();
		Method method = actionContext.getMethod();

		HttpSession session = request.getSession(false);
		if (session == null) 
			throw new ServiceException(Keys.MSG_CODE);
		

		CorpMobile corpMobile = (CorpMobile) session.getAttribute(Keys.SESSION_KEY_CORPMOBILE);
		if (corpMobile == null)
			throw new ServiceException(Keys.MSG_CODE);

		return null;
	}

"应该"? 之前不是试出来,注释掉这个拦截器就正常吗? 不应该继续查下去吗?

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