NutzCN Logo
问答 使用验证码时,日志中产生大量的报错。
发布于 3276天前 作者 lrw124 2134 次浏览 复制 上一个帖子 下一个帖子
标签:

code:
try {
ImageIO.write(image, "JPEG", response.getOutputStream());//将内存中的图片通过流动形式输出到客户端
//如果改成下面这种形式也产生大量的报错日志
//JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
//encoder.encode(image);
//out.flush();
//out.close();
} catch (Exception e) {///ClientAbortException:java.io.IOException
//out.close();
e.printStackTrace();
}
Tomcat logs:
ClientAbortException: java.io.IOException
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:364)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:326)
at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)
at javax.imageio.stream.FileCacheImageOutputStream.close(FileCacheImageOutputStream.java:238)
at javax.imageio.ImageIO.write(ImageIO.java:1580)
at cn.ucte.common.util.ImageUtil.doPost(ImageUtil.java:93)
at cn.ucte.common.util.ImageUtil.doGet(ImageUtil.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.nutz.mvc.NutFilter.nextChain(NutFilter.java:208)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:186)
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:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

3 回复

这问题跟验证码一点关系都没有

真正的问题在于你的页面, "ClientAbortException"产生的原因是 "一个浏览器请求还没完成, 页面就跳转了"

换个说法,就是某个页面上的验证码还没加载完, 页面就跳转了, 检查你的页面吧

没找到原因,折腾好久了。三者有值才提交,验证正确后才跳转。否则刷新验证码。
if ($('#uid').val() != "") {
if ($('#password').val() != "") {
if ($('#verifcode').val().length==4) {
jQuery.ajax({
url : "${ctxPath}/doLogin",
data : jQuery("#form1").serialize(),
type:"POST",
success : function (res) {
if (res == "true") {
window.location.href="${ctxPath}/index";
} else {
Dialog.alert(res);
$('#verifcode').val("");
tochange();//刷新验证码
}
return false;
},
error : function(res) {
Dialog.alert("系统错误?!");
}
});

@lrw124 开chrome控制台,network,勾选prevent log,观察整个请求过程发起的请求,如果期间服务器有报错误,那chrome里面肯定能看到出错的请求

来自炫酷的 NutzCN

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