【maven】maven命令启动,tomcat配置虚拟路径

一、纯tomcat启动,无eclipse等IDE

在tomcat的server.xml文件中找到<Host></Host>

然后在</Host>之前:<Context path="/image" docBase="C:/upload/image"></Context>

然后浏览器访问:http://localhost:8080/upload/image/test.jpg

相当于打开了   :C:/upload/image/test.jpg

 

二、eclipse 使用tomcat

如果是eclipse中配置的tomcat,找到tomcat的server,操作同上

三、eclipse中 使用maven的命令tomcat:run启动

maven 启动 tomcat 配置映射路径,ContextDoc的两个配置

这样http://localhost:8080/upload/image/test.jpg

等同C:/upload/image/test.jpg

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat6-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
            <update>true</update>
            <server>tomcat6</server>
            <port>${tomcat.port}</port>
            <path>/${tomcat.contextroot}</path>
            <staticContextPath>/image</staticContextPath>
            <staticContextDocbase>C:/upload/image</staticContextDocbase>
            <uriEncoding>utf-8</uriEncoding>
        </configuration>
    </plugin>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值