文章目錄
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
1 package com.helloworld.test; 2 3 public class HelloWorld { 4 5 public String sayHello(){ 6 return "sayHello"; 7 } 8 }
WebContent下新建hello.jsp
1 <%@page import="com.helloworld.test.HelloWorld"%> 2 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 3 pageEncoding="ISO-8859-1"%> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 5 <html> 6 <head> 7 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 8 <title>Insert title here</title> 9 </head> 10 <body> 11 <% 12 HelloWorld hw = new HelloWorld(); 13 System.out.println(hw.sayHello()); 14 %> 15 </body> 16 </html>
右鍵hello.jsp->Run as->Run on service->一路下一步,就回看到結果
這是正常的開發使用的方式