java.lang.UnsupportedClassVersionError: com/servlet/TestServlet has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (无法载入的类 [com.servlet.TestServlet])
原因是jre版本与tomcat版本不匹配,在Esclipse上编译出的.class文件在低版本的tomcat中执行不了,由此只需要在esclipse中更改编译环境,生成符合tomcat版本的.class文件即可。
我的tomcat是9.0.62版本,需要1.8的jre
右键你的项目,Build Path ->configure Build Path 选择需要更换的JDK