String certificatePath = Thread.currentThread().getContextClassLoader().getResource("/").getPath().substring(1).replaceAll("%20", " ") + "certificate/certificate.p12";
String certificatePath = FileUtil.class.getClassLoader().getResource("").getPath().substring(1,FileUtil.class.getClassLoader().getResource("").getPath().length()-1)
+File.separator+"certificate"+File.separator+"certificate.p12";
(1)得到工程目录:request.getSession().getServletContext().getRealPath("")
参数:可具体到包名。
结果:E:\Tomcat\webapps\项目名\文件路径