Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
从 Java 类中检查 Struts 运行时是否存在的最快方法是什么?
正如彼得所提到的,您可以尝试加载org.apache.struts.action.RequestProcessor使用Class.forName("org.apache.struts.action.RequestProcessor"),如果它抛出ClassNotFoundException然后 Struts 不存在。
org.apache.struts.action.RequestProcessor
Class.forName("org.apache.struts.action.RequestProcessor")
ClassNotFoundException
尝试加载或使用您需要的类。如果它不存在,它将分别抛出一个ClassNotFoundException或NoClassDefFoundError。
NoClassDefFoundError