Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用级别层次结构的相对路径(../../)_Java_Xml_Relative Path - Fatal编程技术网

Java 使用级别层次结构的相对路径(../../)

Java 使用级别层次结构的相对路径(../../),java,xml,relative-path,Java,Xml,Relative Path,我想在项目中使用xml文件中的相对路径。我把文件放在下面的位置 D:/SDC-Builds/SRDM2.3.0/SRDM/Svr/IdP/IdPserver/conf/attribute-r.xml 我有其他xml文件需要引用上述位置,我使用以下相对路径独立于机器和文件夹名称。 在D:/SDC Builds/SRDM2.3.0/SRDM/Svr/IdP/IdPserver/others/service.xml中,我使用如下代码 service.xml <srv:Configuration

我想在项目中使用
xml
文件中的相对路径。我把文件放在下面的位置

D:/SDC-Builds/SRDM2.3.0/SRDM/Svr/IdP/IdPserver/conf/attribute-r.xml
我有其他xml文件需要引用上述位置,我使用以下相对路径独立于机器和文件夹名称。
在D:/SDC Builds/SRDM2.3.0/SRDM/Svr/IdP/IdPserver/others/service.xml中,我使用如下代码

service.xml

<srv:ConfigurationResource="../../../../../../IdP/IdPserver/conf/attribute-r.xml">
</srv>


请告诉我是否使用了适当的约定来引用属性-r.xml

如果项目根目录是SRDM,那么需要从可执行路径返回

假设您的exe文件位于SRDM/Svr/bin/EXECUTABLE.exe

您需要在xml中提到

<srv:ConfigurationResource="../IdP/IdPserver/conf/attribute-r.xml"></srv>


当前的工作目录是SRDM/Svr/bin/,在您的情况下,您需要从该目录返回到common junction[Svr]。

“我有其他xml文件需要引用上述位置”-其他xml文件的位置是什么?@PaulStatham请查看我上面更新的查询。我想我已经回答了@NiklasB的问题。请告诉我还有什么需要添加的。没关系,我的眼睛一定有问题。不仅仅是“../conf/attribute-r.xml”你能提供一些额外的细节吗?与当前工作目录类似。您只需使用应用程序本身打印工作目录(请不要从理论上说)。D:/SDC Builds/SRDM2.3.0/SRDM/Svr是我当前的工作目录,那么您的相对路径应该像“/IdP/IdPserver/conf/attribute-r.xml”,因为源文件与当前路径(./)处于相同的位置我们必须提供xml文件路径,但它无法读取。这就是为什么我要使用.././Idp/Idpserver/conf/attribute-r.xmlhello@D D Sridhar,它是在“/Idp/Idpserver/conf/attribute-r.xml”中只工作一个(.)还是(…)