zoukankan      html  css  js  c++  java
  • 2017/2/24日开学测试整理

    1、网络系统开发需要的技术。

        就我所知,我们需要掌握Java web技术,数据库技术等等。需要学会HTMLCSSJavaScript等知识。

    2、课堂测试源程序代码。

    ①登录页面

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>用户登录</title>

    <style type="text/css">

    body,td,th {

    color: #000;

    }

    body {

    background-image: url(image/b6.jpg);

    }

    #form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {

    font-size: 18px;

    }

    #form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {

    font-size: 9px;

    }

    #form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {

    font-size: larger;

    }

    #form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {

    font-size: xx-large;

    }

    #form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {

    font-size: x-large;

    }

    </style>

    </head>

    <body>

    <p><label></label> </p>

    <form id="form1" name="form1" method="post" action="">

      <blockquote>

        <blockquote>

          <blockquote>

            <blockquote>

              <blockquote>

                <blockquote>

                  <blockquote>

                    <blockquote>

                      <blockquote>

                        <blockquote>

                          <blockquote>

                            <blockquote>

                              <p align="center"><strong>用户登录</strong></p>

                            </blockquote>

                          </blockquote>

                        </blockquote>

                      </blockquote>

                    </blockquote>

                  </blockquote>

                </blockquote>

              </blockquote>

            </blockquote>

          </blockquote>

        </blockquote>

      </blockquote>

    </form>

    <p> </p>

    <form action="judge.jsp" method="post">

    <table width="252" border="1" align="center">

      <tr>

        <td width="72"><strong>用户名:</strong></td>

        <td width="164"><input name="num" type="text" /></td>

      </tr>

      <tr>

        <td><strong>密码:</strong></td>

        <td><input name="userpassword" type="password" /></td>

      </tr>

      <tr>

        <td> </td>

        <td><a href="judge.jsp" onclick="link"><input type="submit" name="submit"  value="                登录                   " ></a></td>

      </tr>

    </table>

    </form>

    </body>

    </html>

    ②登录成功页面

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <title>success</title>

    <style type="text/css">

    strong {

    font-size: x-large;

    }

    body,td,th {

    color:#00;

    }

    body {

    background-color:#OCF;

    background-image: url(image/b1.jpg);

    }

    </style>

    </head>

    <body>

    <div align="center">

      <p> </p>

      <p> </p>

      <p> </p>

      <p> </p>

      <p class="a"><em><strong>登录成功!!!  </strong></em></p>

    </div>

    </body>

    </html>

    ②登录失败页面

    <%@ page contentType = "text/html; charset=utf-8" import = "java.sql.*" errorPage = "error.jsp" %>

    <html>

      <head>

      </head>

    <body>

    <div style=text-align:center>

    <%

    String num = request.getParameter("num");

    session.setAttribute("username",num);

    String userpassword = request.getParameter("userpassword");

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//加载数据库驱动,注册到驱动管理器

    String URL="jdbc:sqlserver://localhost:1433;DataBaseName=test";//数据库连接字符串 localhost表示本机也可以用IP地址或者计算机的名字 1433表示服务端口 DataBaseName=ConstructionDB或者DataBaseName=msdb表示数据库的名称

    String username="sa"; //数据库用户名

    String password="123456"; //数据库密码 123

    // conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DataBaseName=msdb","sa","123");//方式一

    Connection connect=DriverManager.getConnection(URL, username, password);

    Statement stmt = connect.createStatement();

    String sql = "select  *  from test where name='"+num+"'and userpassword='"+userpassword+"'";

    ResultSet i = stmt.executeQuery(sql);

    if(i.next())

    {

    response.setHeader("refresh","1;url = index1.html");

    }

    else

    {

    out.println("<script language = 'javaScript'> alert('密码错误,请重新输入用户名!');</script>");

    response.setHeader("refresh","1;url = login.html");

    }

    stmt.close();

    connect.close();

    %>

    </div>

      </body>

    <html>

    ④判断数据库连接情况

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 

    <%@page import="java.sql.Connection"%> 

    <%@page import="java.sql.DriverManager"%> 

    <%@page import="java.sql.SQLException"%> 

    <%@ page import="java.sql.Driver.*" %> 

    <%@ page import="java.util.*" %><!-- 导入所有的Java的资源包 --> 

    <%@ page import="java.sql.*"%><!-- 导入所有的Java数据库的资源包 --> 

    <% 

    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 'index1.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"

    <!--

    <link rel="stylesheet" type="text/css" href="styles.css">

    --> 

    </head> 

    <body> 

    <% 

    try{

    String num = request.getParameter("num");

    session.setAttribute("username",num);

    String userpassword = request.getParameter("userpassword");

    Connection conn=null;

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//加载数据库驱动,注册到驱动管理器

    String URL="jdbc:sqlserver://localhost:1433;DataBaseName=test";//数据库连接字符串 localhost表示本机也可以用IP地址或者计算机的名字 1433表示服务端口 DataBaseName=ConstructionDB或者DataBaseName=msdb表示数据库的名称

    String username="sa"; //数据库用户名

    String password="123456"; //数据库密码 123

    // conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DataBaseName=msdb","sa","123");//方式一

    Connection cn=DriverManager.getConnection(URL, username, password);//方式二

    //创建Connection连接

    Statement stmt = cn.createStatement();

    String sql = "select  *  from test where name='"+num+"'and userpassword='"+userpassword+"'";

    ResultSet i = stmt.executeQuery(sql);

    if(i.next())

    {

    response.setHeader("refresh","1;url = index1.html");

    }

    else

    {

    out.println("<script language = 'javaScript'> alert('密码错误,请重新输入用户名!');</script>");

    response.setHeader("refresh","1;url = login.html");

    }

    stmt.close();

    cn.close();

    }catch(ClassNotFoundException e){

    e.printStackTrace();

    out.println(e.toString()+"<br>驱动类无法加载!");

    }catch(SQLException e){

    e.printStackTrace();

    out.println(e.toString()+"<br>数据库连接不上!");

    }

    %> 

    <br><br><br> 

    </body> 

    </html>

    3、运行结果截图。

    4、课堂测试未完成的原因。

        寒假没有做足工作,一直安装SQL server,没安装上,应该是下载的安装包有问题,缺一个dll文件。也没有学数据库相关知识、Java web知识,搞不懂各种文件的作用,需要什么配置。总之,在家没有积极主动的学,以后定会自主学习,因为IT行业对自学能力要求极高。

    5、对这门课的希望和自己的目标。

        我希望自己能够通过这门课,可以自己设计一些简单的网页,并对数据库有所掌握。

  • 相关阅读:
    Python 模块,数据类型,元组
    Python条件循环判断
    Python简介
    File对象的基本操作学习
    File对象的基本操作学习
    sublime学习心得
    sublime学习心得
    IO学习
    IO学习
    Emacs学习
  • 原文地址:https://www.cnblogs.com/hjy415/p/6485912.html
Copyright © 2011-2022 走看看