如何实现通过IP地址直接访问tomcat中应用

在工作的过程中遇到了这个问题,尝试了很多办法都没有实现,最后通过下面介绍的方法实现了。现在就给大家介绍一下如何实现通过IP地址直接访问tomcat中应用。

之前从网上查询了很久,试过了修改regedit文件值,没有效果,尝试修改server.xml文件,修改该部分

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
	<Context path="" docBase="你的项目名" debug="0" reloadable="true"/>

结果无效,依旧无法实现目的。

最后尝试将/webapps/root/下文件删除,重新编写一个html跟jsp去实现这个目的。

删除ROOT文件中的内容,创建一个index.html文件,将下列代码复制过去,修改项目html所在路径,该路径以webapps为根目录,修改完后保存。

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
</head>
<body>
<meta http-equiv="refresh" content="1;url=项目html地址"></body>
</html>

再创建一个名为index.jsp文件,进入文件编辑,将下列代码复制保存。

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%response.sendRedirect("/portal"); %>

此时,修改server.xml文件中的端口即可。

    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值