快速搭建J2EE开发环境主要配置参数

来源:互联网 发布:ie不能登录淘宝网 编辑:程序博客网 时间:2024/05/16 15:27

文件准备:JDK、Myeclipse8.6、tomcat6.0


1、jdk1.6和Myeclipse8.6的安装,解压tomcat


2、配置JDK的环境变量,Tomcat环境变量无需指定

系统变量→新建 JAVA_HOME 变量 。变量值填写jdk的安装目录(例如 E:\Java\jdk1.7.0)

系统变量→寻找 Path 变量→编辑     %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

系统变量→新建 CLASSPATH 变量   .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar(注意最前面有一点)

测试:cmd 输入 java -version

3、为Myeclipse8.6指定jdk1.6和Tomcat6.0的运行环境

Preferences/Java/Installed JREs/Add进行添加

Preferences/MyEclipse Enterprise Workbench/Servers/Tomcat,选择对应版本进行添加


4、新建javaweb工程测试连通性,http://localhost:8080


5、关闭html,jsp等页面的可视化编辑器

 preferences-> General-> Editors -> File Associations在上方框内选择*.jsp(或*.html),在下方框内选择MyEclipse JSP Editor(或MyEclipsehtml Editor),按Default即可。

6、Servlet、Jsp模版修改(可用EditPlus修改)

Servlet修改: 找到MyEclipse安装目录下的\Common\plugins文件夹,比如:D:\MyEclipse10\Common\plugins\com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar\templates\Servlet.java

模版代码:

#---------------------------------------------#
# <aw:description>Template for Servlet</aw:description>
# <aw:version>1.1</aw:version>
# <aw:date>04/05/2003</aw:date>
# <aw:author>Ferret Renaud</aw:author>
#---------------------------------------------#

<aw:import>java.io.IOException</aw:import>
<aw:import>java.io.PrintWriter</aw:import>

<aw:import>javax.servlet.ServletException</aw:import>
<aw:import>javax.servlet.http.HttpServlet</aw:import>
<aw:import>javax.servlet.http.HttpServletRequest</aw:import>
<aw:import>javax.servlet.http.HttpServletResponse</aw:import>

<aw:parentClass>javax.servlet.http.HttpServlet</aw:parentClass>


<aw:method name="doGet">
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

}

</aw:method>

<aw:method name="doPost">

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}

</aw:method>



Jsp修改:(删除部分)

D:\MyEclipse10\Common\plugins\com.genuitec.eclipse.wizards_9.0.0.me201108091322.jar\templates\jsp\jsp.vtl

#*---------------------------------------------#
# Template for a JSP
# @version: 1.2
# @author: Ferret Renaud
# @author: Jed Anderson
#---------------------------------------------#
*#<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP '$title' starting page</title>
    
  </head>
  
  <body>
    This is my JSP page. <br>
  </body>
</html>



7、数据库的安装

0 0
原创粉丝点击