Java Dynamic Web Project

来源:互联网 发布:哈登什么水平知乎 编辑:程序博客网 时间:2024/05/22 15:27

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运行
这里写图片描述

运行结果:
这里写图片描述