课后做业1

一、网站系统开发须要掌握的技术css

1、界面和用户体验(Interface and User Experience)html

1.1 知道如何在基本不影响用户使用的状况下升级网站。一般来讲,你必须有版本控制系统(CVS、Subversion、Git等等)和数据备份机制(backup)。前端

1.2 除了浏览器,网站还有其余使用方式:手机、屏幕朗读器、搜索引擎等等。你应该知道在这些状况下,你的网站的运行情况。MobiForge提供了手机网站开发的一些相关知识。html5

 

2、安全性(Security)java

2.1 不要明文(plain-text)储存用户的密码,要hash处理后再储存。mysql

2.2 确认你的数据库链接信息的安全性。jquery

 

3、性能(Performance)git

3.1 只要有可能,就使用缓存(caching)。正确理解和使用HTTP cachingHTML5离线储存程序员

3.2 学习如何用gzip/deflate压缩内容(deflate方式更可取)。web

3.3 浏览Yahoo的Exceptional Performance网站,里面有大量提高前端性能的优秀建议,还有他们的YSlow工具。Google的page speed则是另外一个用来分析网页性能的工具。二者都要求安装Firebug

3.4 若是你的网页用到大量的小体积图片(好比工具栏),就应该使用CSS Image Sprite,目的是减小http请求数。

3.5 大流量的网站应该考虑将网页对象分散在多个域名split components across domains)。

3.6 静态内容(好比图片、CSS、JavaScript、以及其余cookie无关的网页内容)都应该放在一个不须要使用cookie的独立域名之上。由于域名之下若是有cookie,那么客户端向该域名发出的每次http请求,都会附上cookie内容。这里的一个好方法就是使用"内容分发网络"(Content Delivery Network,CDN)。

3.7 确保网站根目录下有favicon.ico文件,由于即便网页中根本不包括这个文件,浏览器也会自动发出对它的请求。因此若是这个文件不存在,就会产生大量的404错误,消耗光你的服务器的带宽。

 

4、搜索引擎优化(Search Engine Optimization,SEO)

4.1知道robots.txt的做用,以及搜索引擎蜘蛛的工做原理。

4.2使用Google的Webmaster ToolsYahoo的Site Explorer

4.3知道存在着恶意或行为不正当的网络蜘蛛。

4.4若是你的网站有非文本的内容(好比视频、音频等等),你应该参考Google的sitemap扩展协议

 

5、技术(Technology)

5.1 理解HTTP协议,以及诸如GET、POST、sessions、cookies之类的概念,包括"无状态"(stateless)是什么意思。

5.2 确保你的XHTML/HTMLCSS符合W3C标准,使得它们可以经过检验。这可使你的网页避免触发浏览器的古怪行为(quirk),并且使它在"屏幕朗读器"和手机上也能正常工做。

5.3 理解浏览器如何处理JavaScript脚本。

5.4 理解网页上的JavaScript文件、样式表文件和其余资源是如何装载及运行的,考虑它们对页面性能有何影响。在某些状况下,可能应该将脚本文件放置在网页的尾部

5.5 理解JavaScript沙箱(Javascript sandbox)的工做原理,尤为是若是你打算使用iframe。

5.6 知道JavaScript可能没法使用或被禁用,以及Ajax并非必定会运行。记住,"不容许脚本运行"(NoScript)正在某些用户中变得流行,手机浏览器对脚本的支持千差万别,而Google索引网页时不运行大部分的脚本文件。

5.7 了解301重定向和302重定向之间的区别(这也是一个SEO相关问题)。

5.8 考虑使用样式表重置Reset Style Sheet)。

5.9 考虑使用JavaScript框架(好比jQueryMooToolsPrototype),它们可使你不用考虑浏览器之间的差别。

 

6、解决bug

6.1 理解程序员20%的时间用于编码,80%的时间用于维护,根据这一点相应安排时间。

6.2 创建一个有效的错误报告机制。

6.3 创建某些途径或系统,让用户能够与你接触,向你提出建议和批评。

6.4 为未来的维护和客服人员撰写文档,解释清楚系统是怎么运行的。

6.5 常常备份!(而且确保这些备份是有效的。)除了备份机制,你还必须有一个恢复机制。

6.6 使用某种版本控制系统储存你的文件,好比SubversionGit

6.7 不要忘记作单元测试(Unit Testing),Selenium之类的框架会对你有用。

二、源代码

import java.awt.event.*;

import java.awt.*;

import javax.swing.*;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

class B extends JFrame implements ActionListener  

{   

   JPanel Interface = new JPanel(null)         

{

  public void paintComponent(Graphics g)

     {

      super.paintComponent(g);

      ImageIcon img = new ImageIcon("D:\\图片\\6.jpg");

      g.drawImage(img.getImage(),0,0,getWidth(),getHeight(),img.getImageObserver());

     }

};

   JButton Determine=new JButton("肯定");

   JLabel Prompt;

   B(int a)

{

 if(a==1)

   Prompt=new JLabel("用户名不存在!");

 if(a==2)

       Prompt=new JLabel("密码错误!");

 if(a==3)

   Prompt=new JLabel("登录成功!");

 if(a==4)

   Prompt=new JLabel("请输入用户信息!");

 Prompt.setBounds(50,30,150,23);

 Determine.setBackground(Color.WHITE);

 Determine.setForeground(Color.black);

 Determine.setBounds(103,60,64,25);

 Determine.setFont(new Font("黑体",Font.PLAIN,15));

 Prompt.setFont(new Font("黑体",Font.PLAIN,15));

 Prompt.setHorizontalAlignment(SwingConstants.CENTER);

 Prompt.setForeground(Color.black);

 Interface.add(Prompt);

 Interface.add(Determine);

 getContentPane().add(Interface);

 Determine.addActionListener(this);

     setTitle("提示");

     setSize(250,150);                 

     setVisible(true);

     setResizable(false);

     setLocationRelativeTo(null);

     setLayout(new GridLayout());                  

     setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);   

   }

   public void actionPerformed(ActionEvent e)       

 {

      dispose();

 }

}

class A extends JFrame implements ActionListener

{  

    JPanel Interface = new JPanel(null)          

 {

   public void paintComponent(Graphics g)

         {

          super.paintComponent(g);

      ImageIcon img=new ImageIcon("D:\\图片\\11.jpg");

      g.drawImage(img.getImage(),0,0,getWidth(),getHeight(),img.getImageObserver());

         }

 };

    JLabel[] title = new JLabel [2];          

    JTextField getid = new JTextField();

    JPasswordField getcode = new JPasswordField();

    JButton Land = new JButton("登陆");

    A()

 {

   for(int i=0;i<2;i++)  

   title[i]=new JLabel();

   title[0].setText("用户名:");

   title[1].setText("密 码:");

   title[0].setBounds(90, 70, 50, 23);

       getid.setBounds(140,70,150,23);

       title[1].setBounds(90, 110, 50, 23);

       getcode.setBounds(140,110,150,23);

       Land.setBounds(100,180,180,25);

       Land.setBackground(Color.cyan);

       Land.setForeground(Color.black);

   for(int i=0;i<2;i++)

         {

   title[i].setFont(new Font("黑体",Font.PLAIN,13));

   title[i].setForeground(Color.black);

         }

       Land.setFont(new Font("黑体",Font.PLAIN,15));

       Interface.add(title[0]);  

       Interface.add(getid);

       Interface.add(title[1]);

       Interface.add(getcode);

       Interface.add(Land);              

       Land.addActionListener(this);

       getContentPane().add(Interface);

       setTitle("登录窗口");

       setSize(400,300);  

       setVisible(true);

       setResizable(false);

       setLocationRelativeTo(null);

       setLayout(new GridLayout());                  

       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

  public void actionPerformed(ActionEvent e)        //触发事件后的处理方法

    {

       String str1=null;

       String str2=null;

       str1=getid.getText().replaceAll(" ","");

       str2=String.valueOf(getcode.getPassword()).replaceAll(" ","");

       boolean result1=true;

     if(str1==null||str1.equals(""))

     result1=false;

     if(str2==null||str2.equals(""))

     result1=false;

       if(result1)

       {

       int result2=queryresult(str1,str2);

          if(result2==0)

            new B(1);

          if(result2==1)

            new B(2);

          if(result2==2)

            new B(3);

       }

      else

        new B(4);

    }

  public int queryresult(String id,String code)

    {    

    String conURL="jdbc:mysql://localhost:3306/mysql";

     int result=0;

     try

       {

Class.forName("com.mysql.jdbc.Driver");

   }

     catch (java.lang.ClassNotFoundException e1)

        {

 System.out.println(e1.getMessage());

    }      

    try {

     Connection con;

 con = DriverManager.getConnection(conURL,"root","root");

 Statement add=con.createStatement();

 String str="select * from student";

     ResultSet rs=add.executeQuery(str);

     while(rs.next())

      {

       String a1;

       String a2;

       a1=rs.getString("用户名");

       a2=rs.getString("用户密码");

       if(a1.equals(id))

         {

          if(a2.equals(code))

            result=2;

          else

          result=1;

         }

      }

    rs.close();

    con.close();

   }

 catch (SQLException e)

  {

e.printStackTrace();

System.out.println(e.getMessage());

  }   

    return result;

    }

}

public class Example4

{

  public static void main(String[] args)

{

 new A();

}

}

三、截图

四、但愿与目标

但愿能按时完成老师要求的各类任务,在学有余力的状况下提早学习相关的知识,提升自主学习能力,与老师创建良好的师生关系,能多参加相关的比赛。

时间:除了课程与上机外,在完成其余必须作的事情后,会利用闲暇时间来编程,保证每周在课下至少编程6小时。

相关文章
相关标签/搜索