我相信你的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”是链接吗? –