您的位置:首页 > 运维架构 > Tomcat

在tomcat中直接发布文件

2013-10-28 21:26 253 查看
index.html文件

<html>
<head>
<title>欢迎进入CSDN页面</title>

<!--源信息--><!--
<meta http-equiv="keywords"

content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my

page">
<meta http-equiv="content-type" content="text/html;

charset=UTF-8">
-->

<!--css文件-->
<link rel="stylesheet" type="text/css"

href="./css/css.css">

<!--./当前目录下-->
<!--../当前目录上一级目录 下-->

<!--javascript文件-->
<script type="text/javascript"

src="./script/script.js"></script>

<!--写入css文件<style  type="text/css"></style>-->
<!--@IMPORT url(""); 放在style标签中-->
</head>
<body>
<div  id="mainDiv"> 张小婷</div>
</body>
</html>


css.css文件

#mainDiv{
text-align:center;
background-color:#33CC00;
}

script.js文件

alert("你好");


web.xml文件:Web.xml文件是整个web应用中最重要的配置文件,它必须放在WEB-INF目录中。在开发web应用时,但凡涉及到对web应用中的web资源进行配置,通通是在web.xml文件中进行设置。

注意:通过web.xml文件把某个web资源配成网站首页。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<welcome-file-list>
<welcome-file>shouye.html</welcome-file>
</welcome-file-list>

</web-app>


shouye.html文件

<html>
<head>
</head>
<body>
<div >欢迎进入我的网站!!! </div>
</body>
</html>


1.开启服务器Tomcat访问HTML文件

2.若想改变地址或端口号来访问html文件的方法是

(1)首先改在tomcat目录下的conf下的文件server.html

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" /><!--改端口号-->

<Host name="yan_mei"  appBase="webapps"
unpackWARs="true" autoDeploy="true"></Host><!--改地址-->

(2)改地址前可能会出现问题,找不到文件,解决办法

在c盘下的C:\Windows\System32\Drivers\etc的文件下修改hosts

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
127.0.0.1       yan_mei


 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: