Java Dynamic Web Project

Java Dynamic Web Project

1、創建Dynamic Web Project
這裏寫圖片描述

2、設置Target runtime,web容器即Apache Tomcat以及容器配置
這裏寫圖片描述

3、source folder
、

4、web module,記得勾選產生web.xml部署描述文檔,點擊finish按鍵完成工程創建
這裏寫圖片描述
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>dynamicwebprj</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

5、右擊WebContent添加 java server page — index.jsp
web.xml中已配置文檔,程序運行時界面
這裏寫圖片描述
index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>dynamic web project</title>
</head>
<body>
Hello,World!
<%="Hello World!" %>
<% System.out.println("hello world!"); %>
</body>
</html>

6、運行工程
這裏寫圖片描述

7、配置server
這裏寫圖片描述

8、添加工程到web容器,點擊finish運行
這裏寫圖片描述

運行結果:
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章