JavaWeb核心编程之使用Eclipse开发JavaWEB项目

文章目录

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->一路下一步,就回看到结果

这是正常的开发使用的方式

 

posted @ 2016-07-15 21:38  安仲炜  阅读(8928)  评论(0编辑  收藏  举报