【问题标题】:Deploying to Tomcat by ANT通过 ANT 部署到 Tomcat
【发布时间】:2012-09-12 08:45:18
【问题描述】:

我正在尝试像此示例中那样部署 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”?还是有其他想法?谢谢。

【问题讨论】:

    标签: java tomcat deployment ant


    【解决方案1】:

    替换没有问题,参数被urlencoded是正常的。如果不编码,服务器将无法接收。

    而“403”的意思是“禁止”。

    我想这是因为你有一个奇怪的 URL。替换

    task.setUrl("http://localhost:8080/manager/text");
    

    通过

    task.setUrl("http://localhost:8080/manager");
    

    【讨论】:

      【解决方案2】:

      我解决了。

      在“服务器位置”中的 Eclipse 中的 Tomcat 服务器概述(右键单击服务器 -> 打开)中,我必须选择 secons 单选按钮“使用 Tomcat 安装”(默认情况下它设置为第一个“使用工作区元数据”。

      因为在默认情况下,Tomcat 在没有这种情况下需要的管理器应用程序的情况下启动。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多