文章目录
1.eclipse切换到javaee项目
2.创建服务器(如果没有server选项, 怎么做)
3.定制新建面板内容
4.创建动态web工程
1.eclipse切换到javaee项目 如图
2.创建服务器(如果没有server选项, 怎么做)
一般来说eclipse下半区都会有一个service操作卡 ,如果没有
这里给了提示, 点击
3.定制新建面板内容
4.创建动态web工程
file->new->Dynamic Web project
project name: helloworld(其余默认)->next->next->(Generate web.xml deployment descriptor)打上对勾->finish
新建包 com.helloworld.test
新建class HelloWorld.java
package com.helloworld.test; public class HelloWorld { public String sayHello(){
return "sayHello";
}
}
WebContent下新建hello.jsp
<%@page import="com.helloworld.test.HelloWorld"%>
<%@ 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>Insert title here</title>
</head>
<body>
<%
HelloWorld hw = new HelloWorld();
System.out.println(hw.sayHello());
%>
</body>
</html>
右键hello.jsp->Run as->Run on service->一路下一步,就回看到结果
这是正常的开发使用的方式