手把手教你ExtJS从入门到放弃——篇二(ExtJS代码编写环境搭建,代码提示设置及helloworld弹框demo编写)

使用的myeclipse,别问我为什么,公司项目大家都用的myeclipse,正好视频课程也是用myeclipse

软件准备

分享资源(链接在篇一)里都有,API也有,不想看视频的看下面

java开发IDE:myeclipse10 http://www.myeclipseide.com

spket-1.6.23插件下载 http://download.csdn.net/detail/fionamws/4350925

浏览器:FireFox http://firefox.com.cn/download/

数据库:MySQL下载地址 http://dev.mysql.com/downloads/

Ext开发包,我们可以从官方网站里进行下载 http://www.sencha.com/products/extjs/download

 Ext开发包目录结构说明

builds目录为ExtJS压缩后的代码

docs目录为ExtJS的文档

examples目录中是官方的演示示例

locale是多国语言的资源文件,其中ext-lang-zh_CN.js是简体中文

overview是ExtJS的功能概述 pkgs中是ExtJS各部分功能的打包文件

resource中书ExtJS要用到的图片文件与样式表文件

src目录是未压缩的源码 bootstrap.js是ExtJS库的引导文件,通过参数可以自动切换ext-all.js和ext-debug.js

ext-all.js文件是ExtJS的核心库,是必须要引入的

ext-all-debug.js文件是-all.extjs的调试版,在调试的时候可能需要使用

 进入配置开发环境的正题

1.新建工作空间,把workspace与jsp的默认编码都改为UTF-8

2.把下载好的插件包放到myeclipse的dropings文件夹下

3.将js的默认打开编辑器改为如下

4.添加代码提示,之前学js的时候没代码提示,都不知道自己怎样挺过去的,现在没提示完全受不了,如下:

插件包添加进去后重新启动就可以看到Speket目录,双击JavaScript Profile --》new 随便取个名字我这里是ExtJS

--》add library 选择 ExtJS --> add file 选择下载好的提示文件,勾选all 这一项即可,注意:全部选中没效果

 helloworld 弹窗小demo编写 

入门java时就是main方法里控制台打印 helloworld,2016年九月入java的坑,不知不觉已经两年了

1.新建web工程

2.若没有web.xml则要新建,然后配置首页如下

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

3.index.jsp中内容如下(养成好习惯,js代码别写在jsp里)

<%@ 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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- ext的样式文件 -->
    <link rel="styleSheet" type="text/css" href="js/extjs/resources/css/ext-all.css" />
    <!-- extjs的核心文件 -->
    <script type="text/javascript" charset="utf-8" src="js/extjs/ext-all-debug.js"></script>
    <!-- 国际化文件 -->
    <script type="text/javascript" charset="utf-8" src="js/extjs/ext-lang-zh_CN.js"></script>
    <script type="text/javascript" charset="utf-8" src="test.js"></script>
  </head>
  <body>
    This is my JSP page. <br>
  </body>
</html>

4.test.js中内容如下,这里你还想复制粘贴就太懒了

5.将项目部署到tomcat,然后页浏览器访问效果如下

猜你喜欢

转载自blog.csdn.net/JavaCoder_juejue/article/details/84204424