- 浏览: 24396 次
文章分类
最新评论
web应用开发入门(1)-使用eclipse搭建tomcat下web应用项目详细步骤
- 博客分类:
- web应用开发
以下是对第一次学习web应用开发的朋友而写。具体步骤如下:
1、建立基于j2ee的web应用开发工具目录 c:\j2ee
2、安装JDK、JRE
2.1、下载JDK,地址为:
2.2、安装JDK、JRE
运行jdk-6u32-ea-bin-b03-windows-amd64-29_feb_2012.exe,在安装过程中将JDK安装于C:\j2ee\Java\jdk1.6.0_32\下,将JRE安装于C:\j2ee\Java\jre6\下。
3、安装tomcat
3.1、下载tomcat,地址为:
http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.exe
3.2、安装tomcat
运行apache-tomcat-6.0.35.exe,在安装过程中选择jre路径为C:\j2ee\Java\jre6。
点击Next按钮
点击Install按钮完成tomcat的安装。
4、安装开发支持包
...
5、安装eclipse
5.1、下载eclipse,地址为http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/indigo/SR2/eclipse-jee-indigo-SR2-win32-x86_64.zip&url=http://mirrors.ustc.edu.cn/eclipse/technology/epp/downloads/release/indigo/SR2/eclipse-jee-indigo-SR2-win32-x86_64.zip&mirror_id=1093
5.2、安装eclipse
使用winrar压缩工具,将 eclipse-jee-indigo-SR2-win32-x86_64.zip 解压到 C:\j2ee下,\eclipse 目录下
5.3、适当修改eclipse启动配置文件C:\j2ee\eclipse\eclipse.ini中的内存参数,比如说如下:
-Xms512m
-Xmx1536m
-XX:PermSize=256m
-XX:MaxPermSize=768m
6、安装用于eclipse的tomcat插件
6.1、下载tomcat插件,地址为:
http://www.eclipsetotale.com/tomcatPlugin/tomcatPluginV33.zip
6.2、安装tomcat插件
使用winrar压缩工具,将tomcatPluginV33.zip解压到eclipse的插件目录C:\j2ee\eclipse\plugins下。
7、执行C:\j2ee\eclipse\eclipse.exe
7.1、在启动过程中,设置workspace文件夹,比如说c:\workspace
7.2、检查工具栏中有3个tomcat插件相关的图标按钮。
7.3、配置tomcat可以在eclipse中启用停用的选项
菜单路径:Window > Preferences
- 鼠标左键单击左边列表框中的Tomcat
- 鼠标左键单击右上的Tomcat版本,选择Version 6.x
- 填写Tomcat安装目录c:\j2ee\Tomcat 6.0
- 对于Context declaration mode选择单选按钮Server.xml
- 鼠标左键单击OK按钮
- 鼠标左键单击eclipse工具栏中的“Start Tomcat”图标按钮,启动tomcat,测试tomcat的配置的正确性
在eclipse的控制台中显示的信息如下:
2012-3-20 21:28:41 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\j2ee\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows7Master;C:\Program Files (x86)\Lenovo\Access Connections\;C:\PROGRA~2\IBM\SQLLIB\BIN;C:\PROGRA~2\IBM\SQLLIB\FUNCTION;C:\PROGRA~2\IBM\SQLLIB\SAMPLES\REPL;.
2012-3-20 21:28:42 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-3-20 21:28:42 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1959 ms
2012-3-20 21:28:42 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-3-20 21:28:42 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-3-20 21:28:42 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-3-20 21:28:43 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-3-20 21:28:43 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-3-20 21:28:43 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-3-20 21:28:44 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-3-20 21:28:44 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-3-20 21:28:44 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-3-20 21:28:44 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2012-3-20 21:28:44 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-3-20 21:28:44 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=1/79 config=null
2012-3-20 21:28:44 org.apache.catalina.startup.Catalina start
信息: Server startup in 2481 ms
- 鼠标左键单击eclipse工具栏中的“Stop Tomcat”图标按钮,停止Tomcat的运行。
7.4、配置eclipse针对tomcat Server的运行环境,选择菜单
菜单路径:Window > Preferences
7.5、设置eclipse字段集编码,选择菜单
菜单路径:Window > Preferences
7.5.1、设置workspace的字符集编码
7.5.2、设置jsp文件的字符集编码
8.、创建一个简单的web project
8.1、新建一个web工程
菜单路径:File > New > Dynamic Web Project
可以看到以下结果:
8.2、设置项目的tomcat的配置信息
点击Project Explorer中的项目根结点后,选择菜单
菜单路径:Project > Properties
查看C:\j2ee\Tomcat 6.0\conf\server.xml文件,可以看到有以下一段信息:
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
<Context path="" reloadable="true" docBase="C:\workspace\MyWebApp\WebContent" workDir="C:\workspace\MyWebApp\work" />
</Host>
</Engine>
</Service>
</Server>
8.3、创建项目的默认页面default.jsp
点击工程下WebContent文件夹,右击鼠标后,选择菜单New
> JSP File
显示画面如下:
输入文件名default.jsp后,点击Finish按钮,编辑default.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello, this is my first web application!
</body>
</html>
8.4、在eclipse中启动tomcat
8.5、在浏览器中输入地址http://localhost:8080
可以看到以下结果:
相关推荐
主要内容包括web应用程序运行原理、主流集成开发工具(eclipse/myeclipse)和运行环境(tomcat)的配置和使用、servlet、jsp、jdbc、jsp表达式语言(el)、servlet监听器和过滤器、定制标记库、jstl、mvc模式、dao...
Eclipse+Tomcat开发web应用项目建设
《贯通Java Web开发三剑客:Eclipse+Tomcat+Ant整合开发》.part2.rar
ARM DS-5 Eclipse 集成开发环境使用手册v5.16 ,Eclipse使用环境介绍。
本人原创。图文并茂,详细讲述了安装JDK、Tomcat以及Eclipse4EE开发工具的过程及在工具中开发、发布、运行Web项目的基本方法。同时还说明了MySQL及其界面管理工具SQLYog的安装及使用。
通过本人在多次搭建此类开发平台的经验和查阅的相关资料总结整理出搭建Eclipse+Tomcat+Oracle 开发平台的相信过程,帮助你消除搭建开发环境中的问题。
http搭建-eclipse-tomcat-mysql......... 说明文档步骤较多
eclipse部署tomcat开发web项目的配置,详细的图文教程
1. 开发环境的搭建 - 1 - 1.1. 开发工具 - 1 - 1.2. 搭建开发环境 - 1 - 2. 开发Web项目 - 1 - 2.1. 新建Web项目 - 1 - 2.2. 开发Servlet - 3 - 2.3. 发布Web项目 - 5 - 2.4. 开发JSP - 7 -
《贯通Java Web开发三剑客:Eclipse+Tomcat+Ant整合开发》.part1.rar
eclipse项目配置tomcat步骤
本文档讲述了如何在eclipse配置tomcat的另一种方式,如何在eclipse将java项目转成web项目等
Hibernate Web应用的开发一般经过以下几个步骤: (1)创建数据库。 (2)将Hibernate所需的JAR包复制到WEB-INF/lib下。 (3)创建Hibernate的配置文件。 (4)利用Hibernate的第三方工具或Eclipse的有关插件从...
本书内容循序渐进,实例丰富,从基础知识到工程的创建与实现,都是按照读者的学习习惯一步一步来实现的,开发步骤讲解十分详细,配套光盘中给出了所有的实例源代码和相关的软件,适合在Eclipse平台下从事Web开发的...
Java Web应用开发 07 课堂案例-Eclipse下创建第一个JSP程序.docx 学习资料 复习资料 教学资源
NULL 博文链接:https://flashjava.iteye.com/blog/1715014
Eclipse下Web应用开发的详细配置步骤。Eclipse下Web应用开发的详细配置步骤。
eclipse-tomcat-插件
eclipse + tomcat web service
用 Tomcat 和 Eclipse 开发 Web 应用程序