您的位置:首页 > 编程语言 > Java开发

Java Dynamic Web Project

2017-07-13 23:39 246 查看
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运行



运行结果:

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