在使用Tomcat部署服务器之前我们需要写一个页面登录的HTML文本
该文本如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
body {
background-color: pink
}</style>
</head>
<body>
<h1>欢迎login</h1>
<form action="login_success.html" method="post">
用户名:<input type="text" name="username"><br>
密 码: <input type="password" name=psw><br>
<input type="submit" value="login">
</form></body>
</html>
/login/login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>登录成功</h1>
<a href="../index.html" rel="external nofollow" >回首页</a>
</body>
</html>
/login/login_success.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="login/login.html" rel="external nofollow" >我要登录</a>
<a href="" rel="external nofollow" >我要注册</a>
</body>
</html>
index.html
2.下载Tomcat并且启动
1.在官网上下载Tomcat
2.进入bin目录
3.运行setup.bat(如果一闪而过,那么就是环境变量中没有java_home和JRE_HOME的路径,配置就可以了)
4.在浏览器上访问localhost:8080 就可以看到Tomcat的网页(该网页是在webapps/ROOT里面的初始网页)
5.如果8080端口号被占用那么就可以去conf里面修改sever.xml文件修改端口号
3.动态web工程
在动态web工程里面写html需要在webcontert里面写,项目默认找的是index.html如果需要修改默认要在Webcontent/web-inf/web.xml里面修改默认配置(用文本打开)服务器里面的web.xml也有一个默认给index.html的设置
4.部署说明
在STS中部署动态的到Tomcat中是将STS工程按照规则拷到文件夹中,JAVA代码在web-inf文件夹下