2 回答

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超6個(gè)贊
在 web.xml 中,您可以添加
<context-param>
<param-name>you can mention here localtion variable name</param-name>
<param-value>location here </param-value>
</context-param>

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
另一個(gè)答案顯示了將參數(shù)添加到您的web.xml. 51Degrees V3.2 數(shù)據(jù)文件如下所示:
<context-param>
? ? <description>The name of the device database.</description>
? ? <param-name>BINARY_FILE_PATH</param-name>
? ? <param-value>51Degrees-EnterpriseV3_2.dat</param-value>
</context-param>
據(jù)我所知,沒(méi)有辦法獲取位于資源路徑中的資源(它是一個(gè) XML 文件,因此.getResource(name)無(wú)法使用該方法)。但是,由于您有一個(gè)web.xml文件,我認(rèn)為這是一個(gè)網(wǎng)絡(luò)項(xiàng)目(即而.war不是.jar)?如果是這種情況,那么該WEB-INF目錄就是您所需要的。這里的文件也像資源一樣被打包,但可以更容易地被.war包使用。
如果您將數(shù)據(jù)文件放入src/main/webapp/WEB-INF/,該文件將被 Web 項(xiàng)目用作根目錄。因此,如果數(shù)據(jù)文件的路徑是:
src/main/webapp/WEB-INF/51Degrees-EnterpriseV3_2.dat
添加回答
舉報(bào)