From b9986333a0703c327d86c267be373f27a42bc7b5 Mon Sep 17 00:00:00 2001 From: Jered Ye <87924680+JeredYe@users.noreply.github.com> Date: Tue, 16 Jan 2024 21:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9LangSelector=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/src/common/LangSelector.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Common/src/common/LangSelector.java b/Common/src/common/LangSelector.java index f631d47..efbe4cb 100644 --- a/Common/src/common/LangSelector.java +++ b/Common/src/common/LangSelector.java @@ -16,15 +16,14 @@ import org.w3c.dom.Document; * @author Jared Ye */ public abstract class LangSelector { - + // private static String ConfigPath=""; private static Document Data; public static boolean Loaded=false; private static XPath xpath = XPathFactory.newInstance().newXPath(); static { try { - ConfigPath=findConfigFilePath(); - Data = init(ConfigPath); + init(); Loaded=true; } catch (Exception e) { //初始化的时候没有读到config.xml @@ -78,16 +77,18 @@ public abstract class LangSelector { - public static Document init(String ConfigPath) throws Exception { + public static Document init() throws Exception { // 创建Document对象 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); DocumentBuilder db = dbf.newDocumentBuilder(); // 创建XPath对象 - LangSelector.ConfigPath =ConfigPath; + LangSelector.ConfigPath =findConfigFilePath(); //JOptionPane.showMessageDialog(null,"当前工作目录:"+ConfigPath); // LangSelector.ConfigPath=new File(LangSelector.ConfigPath).getAbsolutePath(); - return db.parse(LangSelector.ConfigPath); + Document doc=db.parse(new File(LangSelector.ConfigPath)); + Data=doc; + return doc; }