没有重写接口方法,IDEA没有报错。
今天在IDEA写拦截器的时候遇到点困惑,继承了HandlerInterceptor没有报错,我一直认为他会提醒,要重写方法。如下图

通过查资料,嗯,终于找到原因来,先来上HandlerInterceptor接口的源码
public interface HandlerInterceptor {
default boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
return true;
}
default void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
@Nullable ModelAndView modelAndView) throws Exception {
}
default void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
@Nullable Exception ex) throws Exception {
}
}
敲一敲黑板,重点来了
以上是HandlerInterceptor 接口的源码,可以看到高版本的spring-webmvc jar包中,HandlerInterceptor 接口定义的是默认方法,这是jdk1.8的新特性,也就是说接口中的方法你重写也可以,不重写也不会报错。
所以所这里并不会提醒你重写,你要自己去手动写。
没有重写接口方法,IDEA没有报错。的更多相关文章
- java调用本地方法的时候报错 could not find the main class:xx.program will exit
如图所示,当在java调用本地方法的时候报错 我的解决办法是把dll文件放到System.out.println(System.getProperty("java.library.path& ...
- IntelliJ IDEA中Mapper接口通过@Autowired注入报错的正确解决方式
转载请注明来源:四个空格 » IntelliJ IDEA中Mapper接口通过@Autowired注入报错的正确解决方式: 环境 ideaIU-2018.3.4.win: 错误提示: Could no ...
- 关于微信JS-SDK 分享接口的两个报错记录
一.前提: 微信测试号,用微信开发者工具测试 二.简单复述文档: 1.引入JS文件 在需要调用JS接口的页面引入如下JS文件,(支持https):http://res.wx.qq.com/open/j ...
- fetch get方法的时候报错
fetch 报错 Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. 翻译过来就 ...
- 接口调用 读取图片报错 Access to the path '' is denied.解决方案
调用接口 读取服务器上 图片 报错: Server was unable to process request. ---> Access to the path '图片路径' is denied ...
- 【原】iOS 同时重写setter和getter时候报错:Use of undeclared identifier '_name';did you mean 'name'
写了那么多的代码了,平时也没有怎么注意会报这个错误,因为平时都很少同时重写setter和getter方法,一般的话,我们大概都是使用懒加载方法,然后重写getter方法,做一个非空判断.然后有时候根据 ...
- 执行发送邮件Send方法时,报错:邮箱不可用。 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com
.net代码在执行发送邮件Send方法时,往往出现这个的报错: 邮箱不可用. 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com 这个问题应该是smtp的设置问 ...
- 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'
一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...
- 解决分批次调用 jsonp 接口的 callback 会报错问题
当我们分批次调用同一个jsonp接口时,会有一定机率同时调用,而jsonp的callback不支持同时调用, 会报错,所以当我们在分批次调用同一jsonp接口时,最好在callback后加个变量值,总 ...
随机推荐
- jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function
jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function 使用.load()绑定事件时报错,Uncaught TypeError: e.i ...
- bolb与base64的图片互转
直接看图简单明了. 注:便于测试你可以自己用base64图片测试互转一下.这里base64图片太长了就不给予展示了,望理解
- pycharm配置docker
- hex2pcap
#include <stdlib.h> #include <stdio.h> #include <string.h> typedef struct { unsign ...
- SpringDataRedis入门Demo
步骤: 约定>配置>代码 在pom.xml中导入依赖(redis和jedis以及其他所需的依赖) > 配置相关配置文件(redis-config.properties 和applic ...
- h5py报错:FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
导入h5py的时候,报错: /home/harris/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: ...
- IDEA设置外部比对工具Beyond Compare
设置IDEA使用外部的比对工具,比如Beyond Compare,其实很简单,但是可能好几年才会设置一次,比如换工作的时候,所以记录下来 可以通过菜单File-Settings 或者直接快捷键ctrl ...
- ADO.NET中的5个主要对象
1.Connection:主要是开启程序和数据库之间的连接.没有利用连接对象将数据库打开,是无法从数据库中取得数据的. Close和Dispose的区别,Close以后还可以Open,Dispose以 ...
- NumPy 文件数据读写
写数据 NumPy 数组可以使用 np.save 方法保存到本地磁盘中,默认扩展名是 .npy,并且是未压缩的二进制格式. import numpy as np a = np.array([[0, 1 ...
- java开发高校社团管理系统JSP
运行环境JDK1.7编写Eclipse( Neon.3 Release (4.6.3)) windows下Tomcat v8.5Mysql 5.5使用技术Java servlet & jspM ...