---
title: "在tomcat中，通过IP访问web系统，不需要端口号的方法(转)"
author: "benx"
date: "2012-02-06T11:10:27Z"
tags: []
categories: ["Web前端"]
slug: "tomcat-ip-web"
draft: false
lastmod: "2012-02-06T11:10:27Z"
id: 1394899
url: "https://benx.iteye.com/blog/1394899"
---

源文章地址：[http://sinian.iteye.com/blog/149363](http://sinian.iteye.com/blog/149363)

 

如果想要通过IP直接访问web系统，而不加端口号的话，需要在server.xml文件中进行如下修改：   
    1、把默认的8080端口，改成浏览器请求的默认端口80。 

Java代码  [![收藏代码](http://sinian.iteye.com/images/icon_star.png)](http://sinian.iteye.com/blog/149363 "收藏这段代码")

1. &lt;Connector port="80" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100"connectionTimeout="20000" disableUploadTimeout="true" useBodyEncodingForURI="true"/&gt;

    2、修改Host里的appBase路径，使appBase的值为工程所在路径（/root/aaa），初始页面index.jsp就在aaa文件夹里。 

Java代码  [![收藏代码](http://sinian.iteye.com/images/icon_star.png)](http://sinian.iteye.com/blog/149363 "收藏这段代码")

1. &lt;Host name="localhost" appBase="/root/aaa"
2. unpackWARs="true" autoDeploy="true"  xmlValidation="false" xmlNamespaceAware="false"&gt;

    并在Host下面加入： 

Java代码  [![收藏代码](http://sinian.iteye.com/images/icon_star.png)](http://sinian.iteye.com/blog/149363 "收藏这段代码")

1. &lt;Context docBase="/root/aaa" path="" reloadable="true"&gt;

    然后输入http://127.0.0.1就可以访问web系统的index.jsp页面了。