• java Web相关术语


    1.  htm和html:

    静态网页,通过固定标签实现

     1 <!--
     2 To change this template, choose Tools | Templates
     3 and open the template in the editor.
     4 -->
     5 <!DOCTYPE html>
     6 <html>
     7     <head>
     8         <title>第一个javaScript程序</title>
     9         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    10         <script language="JavaScript"><!-- 使用javascript语言  -->
    11             alert("Hello World!");   //弹出警告框
    12             alert("Hello SCUT!");
    13         </script>
    14 
    15         <script language="javascript" src="hello.js">
    16         </script>
    17         
    18         <script  language="javascript">
    19             document.write("<h1>hello World!!!</h1>");
    20             document.write("<h5>www.scut.edn.cn</h5>");
    21         </script>
    22     </head>
    23     <body>
    24         <h1>这是一个网页~~~</h1>
    25         <script language="JavaScript">
    26             alert("第3个警告框!");
    27         </script>
    28     </body>
    29 </html>
    View Code

    2.  js:javascript

    标签:

    <script language="text/javascript">

    function fun(){

       }

    </script>

     1 <!--
     2 To change this template, choose Tools | Templates
     3 and open the template in the editor.
     4 -->
     5 <!DOCTYPE html>
     6 <html>
     7     <head>
     8         <title>这是js里关于变量var的学习</title>
     9         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    10         <script language="javascript">
    11 
    12             var num = 30;  //定义一个数字
    13             var info = "www.scut.edu.cn";//定义一个字符串
    14             alert("数字:" + num + ";字符串:" + info);
    15 
    16             str = "scut";
    17             if (str === "scut")
    18                 alert("str符合if判断!");
    19             else
    20                 alert("str不符合if判断!");
    21 
    22         </script>
    23 
    24         <!--  使用循环输入5行10列的表格 -->
    25         <script language="javascript">
    26             var row = 5;
    27             var col = 10;
    28             document.write("<table border="1">");// 输出表格
    29             for (i = 0; i < row; i++) {
    30                 document.write("<tr>");
    31                 for (j = 0; j < col; j++) {
    32                     document.write("<td>" + i * j + "</td>");
    33                 }
    34                 document.write("</tr>");
    35             }
    36             document.write("</table>");
    37         </script>
    38 
    39 
    40         <!--输出九九乘法表 -->
    41         <script language="javascript">
    42             document.write("<table border="1">");
    43             for (i = 1; i <= 9; i++) {
    44                 document.write("<tr>");
    45                 for (j = 1; j <= 9; j++) {
    46                     if (j <= i) {
    47                         document.write("<td>" + i + "*" + j + "=" + i * j + "</td>");
    48                     }
    49                     else {
    50                         document.write("<td>&nbsp;</td>");
    51                     }
    52                 }
    53                 document.write("</tr>");
    54             }
    55             document.write("</table>");
    56         </script>
    57 
    58     </head>
    59     <body>
    60     </body>
    61 </html>
    View Code

    3. xml  可拓展的标记性语言

    <name>周mm</name>

     1 <?xml version="1.0" encoding="GB2312"?>
     2 <!--
     3 To change this template, choose Tools | Templates
     4 and open the template in the editor.
     5 -->
     6 <addresslist>
     7     <linkman>
     8         <name>周敏丽</name>
     9         <email>1234567@163.com</email>       
    10     </linkman>
    11     <linkman>
    12         <name>叶子君</name>
    13         <email>7654321@163.com</email>
    14     </linkman>
    15 </addresslist>
    View Code

    (1)xml解析: DOM解析,SAX解析

     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package xmlpackage;
     6 
     7 /**
     8  *
     9  * @author XiaoTianCai
    10  */
    11 /*
    12  * DOM解析xml文件内容
    13  */
    14 
    15 import java.io.IOException;
    16 import javax.xml.parsers.DocumentBuilder;
    17 import javax.xml.parsers.DocumentBuilderFactory;
    18 import javax.xml.parsers.ParserConfigurationException;
    19 import org.xml.sax.SAXException;
    20 import org.w3c.dom.Document;
    21 import org.w3c.dom.Element;
    22 import org.w3c.dom.NodeList;
    23 
    24 public class DOMdemo_test02 {
    25 
    26     public static void main(String[] args) {
    27         //(1)建立DocumentBuilderFactory,以用于取得DocumentBuilder
    28         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    29         //(2)通过DocumentBuilderFactory取得DocumentBuilder
    30         DocumentBuilder builder = null;
    31         try {
    32             builder = factory.newDocumentBuilder();
    33         } catch (ParserConfigurationException e) {
    34             e.printStackTrace();
    35         }
    36 
    37         //(3)定义Document接口对象,通过DocumentBuilder类进行DOM树的转换操作
    38         Document doc = null;
    39         try {
    40             doc = builder.parse("web\xml_test.xml");
    41         } catch (SAXException | IOException e) {
    42             e.printStackTrace();
    43         }
    44         //(4)查找linkman的节点
    45         NodeList nl = doc.getElementsByTagName("linkman");
    46         //(5)输出nodelist中的第一个节点张文本节点的内容
    47         for (int i = 0; i < nl.getLength(); i++) { //循环输出节点内容
    48             Element e = (Element) nl.item(i); //取得第一个元素
    49             System.out.println("姓名:" + e.getElementsByTagName("name").item(0).getFirstChild().getNodeValue());
    50             System.out.println("邮箱:" + e.getElementsByTagName("email").item(0).getFirstChild().getNodeValue());
    51         }
    52     }
    53 }
    View Code

    (2)生成xml文档并保存为磁盘文件:

     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package xmlpackage;
     6 
     7 /**
     8  * @author XiaoTianCai
     9  */
    10 /*
    11  * 生成xml文件并输出到磁盘文件中,
    12  * xml文件不会格式整齐,但实际使用中格式没有任何关系
    13  */
    14 import java.io.File;
    15 import java.io.IOException;
    16 import javax.xml.parsers.DocumentBuilder;
    17 import javax.xml.parsers.DocumentBuilderFactory;
    18 import javax.xml.parsers.ParserConfigurationException;
    19 import javax.xml.transform.OutputKeys;
    20 import javax.xml.transform.Transformer;
    21 import javax.xml.transform.TransformerConfigurationException;
    22 import javax.xml.transform.TransformerException;
    23 import javax.xml.transform.TransformerFactory;
    24 import javax.xml.transform.dom.DOMSource;
    25 import javax.xml.transform.stream.StreamResult;
    26 import org.xml.sax.SAXException;
    27 import org.w3c.dom.Document;
    28 import org.w3c.dom.Element;
    29 import org.w3c.dom.NodeList;
    30 
    31 public class DOMdemo_build_xml_test {
    32 
    33     public static void main(String[] args) {
    34         //(1)建立DocumentBuilderFactory,用于取得DocumentBuilder
    35         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    36         //(2)通过DocumentBuilderFactory,取得DocumentBuilder
    37         DocumentBuilder builder = null;
    38         try {
    39             builder = factory.newDocumentBuilder();
    40         } catch (ParserConfigurationException e) {
    41             e.printStackTrace();
    42         }
    43         //(3)定义Document接口对象,通过DocumentBuilder类进行DOM树的转换操作
    44         Document doc = null;
    45         doc = builder.newDocument();   //创建一个新文档
    46         //(4)建立各个操作节点
    47         Element addresslist = doc.createElement("addresslist");//建立节点
    48         Element linkman = doc.createElement("linkman");
    49         Element name = doc.createElement("name");
    50         Element email = doc.createElement("email");
    51         //(5)设置节点的文本内容,即为每一个节点添加文本节点
    52         name.appendChild(doc.createTextNode("周敏丽"));//设置文本
    53         email.appendChild(doc.createTextNode("1234567@163.com"));
    54         //(6)设置节点关系
    55         linkman.appendChild(name); //子节点
    56         linkman.appendChild(email);
    57         addresslist.appendChild(linkman);
    58         doc.appendChild(addresslist); //文本上的保存节点
    59         //(7)将文档输出到文件中
    60         TransformerFactory tf = TransformerFactory.newInstance();
    61         Transformer t = null;
    62         try {
    63             t = tf.newTransformer();
    64         } catch (TransformerConfigurationException e1) {
    65             e1.printStackTrace();
    66         }
    67         t.setOutputProperty(OutputKeys.ENCODING, "GB2312");  //设置编码
    68         DOMSource source = new DOMSource(doc); //输出文档
    69         StreamResult result = new StreamResult(new File("web\output.xml")); //指定输出位置
    70         try {
    71             t.transform(source, result);
    72         } catch (TransformerException e) {
    73             e.printStackTrace();
    74         }
    75     }
    76 }
    View Code

    (3)xml文件显示:通常加载css层叠样式表

     1 /* 
     2     Document   : attrib
     3     Created on : 2013-7-15, 21:21:22
     4     Author     : XiaoTianCai
     5     Description:
     6         Purpose of the stylesheet follows.
     7 */
     8 name
     9 { 
    10     display: block;
    11     color: blue;
    12     font-size: 20pt;
    13     font-weight: bold;
    14 }
    15 id,conpany,email,tel,site
    16 {
    17     display: block;
    18     color: black;
    19     font-size: 14pt;
    20     font-weight: normal;
    21     font-style: italic;
    22 }
    View Code
     1 <?xml version="1.0" encoding="GB2312" standalone="no"?>
     2 <!--
     3 To change this template, choose Tools | Templates
     4 and open the template in the editor.
     5 -->
     6 <?xml-stylesheet type="text/css" href="attrib.css"?>  <!--引入css样式表-->
     7 <addresslist>
     8     <linkman>
     9         <name>周mm</name>
    10         <id>0001</id>
    11         <company>广二师</company>
    12         <email>nmnmll@qq.com</email>
    13         <tel>020-1124568</tel>
    14         <site>www.zhiaiyaya.com</site>
    15     </linkman>
    16 </addresslist>
    View Code
  • 相关阅读:
    20199319 《深入理解计算机系统》第一章学习总结
    速读《深入理解计算机系统》
    《文献管理与信息分析》快速学习
    速读《构建之法(第三版)》 20199319
    2019-2020-1 20199319《Linux内核原理与分析》第六周作业
    2019-2020-1 20199319《Linux内核原理与分析》第五周作业
    2019-2020-1 20199319《Linux内核原理与分析》第四周作业
    2019-2020-1 20199319《Linux内核原理与分析》第三周作业
    2019-2020-1 20199319《Linux内核原理与分析》第二周作业
    2019-2020-1 20199319《Linux内核原理与分析》第一周作业
  • 原文地址:https://www.cnblogs.com/zhiaiyaya/p/3194028.html
Copyright © 2020-2023  润新知