一.創(chuàng)建web project項目
1.)創(chuàng)建web project 并關(guān)聯(lián)Tomcat服務(wù)器
創(chuàng)建項目【new->web project 】

創(chuàng)建項目

關(guān)聯(lián)Tomcat服務(wù)器
2.)在webRoot下建立靜態(tài)資源文件寫入內(nèi)容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>indext1.html</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">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<h1>你好,這是我的第一個動態(tài)網(wǎng)站的靜態(tài)資源:【W(wǎng)ebRoot】</h1>
</body>
</html>
在WebRoot目錄下創(chuàng)建:【new->HTML】

創(chuàng)建文件

寫入內(nèi)容
3.)在src下創(chuàng)建動態(tài)資源文件寫入內(nèi)容
package one.zzt;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("這是第一個動態(tài)網(wǎng)站的動態(tài)資源:"+new Date());
}
}
在src目錄下創(chuàng)建:new->Servlet(servlet的代碼生成器)

創(chuàng)建動態(tài)資源文件
修改mapping url 訪問時輸入的地址

修改訪問名稱

寫入內(nèi)容
二.部署webProject 并應(yīng)用
1.)拷貝web應(yīng)用到tomcat的webapps目錄下

部署拷貝工程

部署成功
2.)啟動tomcat服務(wù)器

啟動Tomcat
三.)訪問servlet
http ://localhost:8080/NewProject/index.html

訪問動態(tài)網(wǎng)站靜態(tài)資源
http ://localhost:8080/NewProject/Myservlet

訪問動態(tài)網(wǎng)站動態(tài)資源
【完】