开发者社区> 问答> 正文

jfinal控制器报错后的异常信息都是找不到视图?报错

@JFinal 你好,想跟你请教个问题:

如题,每次都跳转到com.jfinal.aop.Invocation

原代码是:

	public void invoke() {
		if (index < inters.length) {
			inters[index++].intercept(this);
		}
		else if (index++ == inters.length) {	// index++ ensure invoke action only one time
			try {
				// Invoke the action
				if (action != null) {
					returnValue = action.getMethod().invoke(target, args);
				}
				// Invoke the method
				else {
					// if (!Modifier.isAbstract(method.getModifiers()))
						// returnValue = methodProxy.invokeSuper(target, args);
					if (useInjectTarget)
						returnValue = methodProxy.invoke(target, args);
					else
						returnValue = methodProxy.invokeSuper(target, args);
				}
			}
			catch (InvocationTargetException e) {
				Throwable t = e.getTargetException();
				throw t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(e);
			}
			catch (RuntimeException e) {
				throw e;
			}
			catch (Throwable t) {
				throw new RuntimeException(t);
			}
		}
	}
<p>
	<br>
</p>
<p>
	<br>
</p>


改为以下代码,就可以查看到sql语句报的异常了

	public void invoke() {
		if (index < inters.length) {
			inters[index++].intercept(this);
		}
		else if (index++ == inters.length) {	// index++ ensure invoke action only one time
				// Invoke the action
				if (action != null) {
					try {
						returnValue = action.getMethod().invoke(target, args);
					} catch (IllegalAccessException e) {
						e.printStackTrace();
					} catch (IllegalArgumentException e) {
						e.printStackTrace();
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}
				}
				// Invoke the method
				else {
					// if (!Modifier.isAbstract(method.getModifiers()))
						// returnValue = methodProxy.invokeSuper(target, args);
					if (useInjectTarget)
						try {
							returnValue = methodProxy.invoke(target, args);
						} catch (Throwable e) {
							e.printStackTrace();
						}
					else
						try {
							returnValue = methodProxy.invokeSuper(target, args);
						} catch (Throwable e) {
							e.printStackTrace();
						}
				}
		}
	}
<p>
	<br>
</p>
<p>
	<br>
</p>

展开
收起
爱吃鱼的程序员 2020-06-09 12:41:37 644 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

       日志没有配置好而已,你这样改源代码的结果,只会在控制台输出,不会输出到log4j配置的日志文件中去,非常不利于生产环境,e.printStackTrace()几乎没有什么合适的使用场合,是学生时代用来看看控制台异常输出的。

    2020-06-09 12:41:55
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载