静态方法内调用非静态方法,使用<类名.方法名>可调用非静态方法
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
Class<?> clazz = classLoader.loadClass("class name");
path 不以’/'开头时默认是从此类所在的包下取资源,以’/'开头则是从ClassPath根下获取。
InputStream in = clazz.getResourceAsStream("/" + CONFIG_JMX_PATH + "/email.html");
String resource = Thread.currentThread().getContextClassLoader().getResource("").toString();
File excelfile = ResourceUtils.getFile(resource + CONFIG_JMX_PATH + "/email.html");
HttpServletRequest thredrequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String realPath = thredrequest.getSession().getServletContext().getRealPath("/");
File excelfile = ResourceUtils.getFile(realPath + "/WEB-INF/classes" + CONFIG_JMX_PATH + "/email.html");