我正在尝试像本例中那样部署 WAR https://stackoverflow.com/a/4144674/758661
DeployTask task = new DeployTask();
task.setUrl("http://localhost:8080/manager/text");
task.setUsername("tomcat");
task.setPassword("s3cret");
task.setPath("/updater");
task.setWar(warFile.getAbsolutePath());
task.execute();
但是得到403错误:
Server returned HTTP response code: 403 for URL:
http://localhost:8080/manager/text/deploy?path=%2Fupdater
我认为这是因为“/”已被替换为“%2F”(密码和用户名就像在tomcat-users.xml 中一样)
如何防止将“/”替换为“%2F”?或者有什么其他的想法吗?谢谢。
最佳答案
替换没有问题,参数被urlencode是正常的。如果不进行编码,服务器将无法接收它。
而“403”的意思是“禁止”。
我想这是因为您有一个奇怪的 URL。替换
task.setUrl("http://localhost:8080/manager/text");
通过
task.setUrl("http://localhost:8080/manager");
关于java - 通过 ANT 部署到 Tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12384340/