我相信你的docBase行屬於server.xml而不是servlet.xml。我也認爲你的路徑變量需要以一個前導斜槓開始。我不知道它是否可以包含兩個級別,您可能只想將其更改爲path =/assets
接下來,查看您的context.xml文件。如果它說
<Context antiResourceLocking="true">
你需要在新文件可用之前重新加載上下文。如果您的Context元素沒有antiResourceLocking =「true」,那麼該文件應該立即可用。
可以以編程方式重新加載情況下,無需重新啓動Tomcat中,通過發出GET請求http://localhost:8080/manager/text/reload?path=/assets(假設你改變你的路徑變量/資產)
但是你可能需要提供一個Authenticator,這樣:
Authenticator.setDefault (new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication ("tomcat", "password".toCharArray());
}
});
URL url = new URL("http://localhost:8080/manager/text/reload?path=/assets");
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
logger.info(response.toString());
in.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
「C:/ assets」是鏈接嗎? –