1.网站系统开发需要掌握的技术

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

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

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

二、安全性(Security)

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

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

、性能(Performance)

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

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

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错误,消耗光你的服务器的带宽。

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

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

4.2使用Google的Webmaster Tools和Yahoo的Site Explorer

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

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

五、技术(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),它们可以使你不用考虑浏览器之间的差异。

 

六、解决bug

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

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

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

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

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

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

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

2.本次课堂测试的源程序代码

/*UserDaoImpl.java*/

 package com.jaovo.msg.dao;

 import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import com.jaovo.msg.Util.DBUtil;
import com.jaovo.msg.Util.UserException;
import com.jaovo.msg.model.User; import sun.net.www.content.text.plain; public class UserDaoImpl implements IUserDao{ @Override
public void add(User user) {
//获得链接对象
Connection connection = DBUtil.getConnection();
//准备sql语句
String sql="select count(*) from test_user where username = ?";
//创建语句传输对象
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, user.getUsername());
//接收结果集
resultSet=preparedStatement.executeQuery();
//遍历结果集
while(resultSet.next())
{
if(resultSet.getInt(1)>0)//>0说明数据库中已存在该用户
{
throw new UserException("用户已存在");
}
}
sql="insert into test_user(username,password) value (?,?)";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, user.getUsername());
preparedStatement.setString(2, user.getPassword());
preparedStatement.executeUpdate();//更改
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(resultSet);
DBUtil.close(preparedStatement);
DBUtil.close(connection);
} } @Override
public void delete(int id) {
Connection connection=DBUtil.getConnection();
String sql="delete from test_user where id = ?";
PreparedStatement preparedStatement=null;
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setInt(1,id);
preparedStatement.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(preparedStatement);
DBUtil.close(connection);
} } @Override
public void update(User user) {
//获得链接对象
Connection connection = DBUtil.getConnection();
//准备sql语句
String sql="update test_user set password = ? , where id = ?";
//创建语句传输对象
PreparedStatement preparedStatement=null;
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,user.getPassword());
preparedStatement.setInt(2, user.getId());
preparedStatement.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(preparedStatement);
DBUtil.close(connection);
}
} @Override
public User load(int id) {
//获得链接对象
Connection connection = DBUtil.getConnection();
//准备sql语句
String sql="select * from test_user where id = ?";
//创建语句传输对象
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
User user=null;
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setInt(1,id);
resultSet=preparedStatement.executeQuery();
while(resultSet.next()) {
user=new User();
user.setId(id);
user.setUsername(resultSet.getString("username"));
user.setPassword(resultSet.getString("password"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(resultSet);
DBUtil.close(preparedStatement);
DBUtil.close(connection);
} return user;
} @Override
public User load(String username) {
//获得链接对象
Connection connection = DBUtil.getConnection();
//准备sql语句
String sql="select * from test_user where username = ?";
//创建语句传输对象
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
User user=null;
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,username);
resultSet=preparedStatement.executeQuery();
while(resultSet.next()) {
user=new User();
user.setId(resultSet.getInt("id"));
user.setUsername(username);
user.setPassword(resultSet.getString("password"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(resultSet);
DBUtil.close(preparedStatement);
DBUtil.close(connection);
} return user;
} @Override
public List<User> load() {
//获得链接对象
Connection connection = DBUtil.getConnection();
//准备sql语句
String sql="select * from test_user";
//创建语句传输对象
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
//集合中只能放入user对象
List<User>users=new ArrayList<User>();
User user=null;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
while(resultSet.next()) {
user=new User();
user.setId(resultSet.getInt("id"));
user.setUsername(resultSet.getString("username"));
user.setPassword(resultSet.getString("password"));
users.add(user);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(resultSet);
DBUtil.close(preparedStatement);
DBUtil.close(connection);
} return users;
} }

/*IUserDao.java*/

 package com.jaovo.msg.dao;
import java.util.List;
import com.jaovo.msg.model.User; public interface IUserDao {
public void add(User user);
public void delete(int id);
public void update(User user);
public User load(int id);
public User load(String username);
public List<User> load(); }

/*User.java*/

 package com.jaovo.msg.model;

 public class User {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

/*UserException.java*/

 package com.jaovo.msg.Util;

 public class UserException extends RuntimeException{

     public UserException() {
super();
// TODO Auto-generated constructor stub
} public UserException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
// TODO Auto-generated constructor stub
} public UserException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
} public UserException(String message) {
super(message);
// TODO Auto-generated constructor stub
} public UserException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}

/*DBUtil.java*/

 package com.jaovo.msg.Util;

 import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; public class DBUtil { public static Connection getConnection() {
try {
//1 加载驱动
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String user = "root";
String password = "root";
String url = "jdbc:mysql://localhost:3306/test";
Connection connection = null;
try {
//2 创建链接对象connection
connection = DriverManager.getConnection(url,user,password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return connection;
} //关闭资源的方法
public static void close(Connection connection ) {
try {
if (connection != null) {
connection.close();
} } catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void close(PreparedStatement preparedStatement ) {
try {
if (preparedStatement != null) {
preparedStatement.close();
} } catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void close(ResultSet resultSet ) {
try {
if (resultSet != null) {
resultSet.close();
} } catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

/*addInput.jsp*/

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户注册界面</title>
</head>
<body>
<%=request.getAttribute("error") %>
<form action="add.jsp" method="get">
<h2 style="color:blue ; font-size:30px">用户注册</h2>
<table align="center" border="1" width="500">
<tr>
<td>用户名称:</td>
<td>
<input type="text" name="username" />
</td>
</tr>
<tr>
<td>用户密码:</td>
<td>
<input type="password" name="password"/>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="注册" />
<input type="reset" name="重置" />
</td>
</tr>
</table>
</form>
</body>
</html>

/*add.jsp*/

 <%@page import="com.jaovo.msg.Util.UserException"%>
<%@page import="com.jaovo.msg.dao.UserDaoImpl" %>
<%@page import="com.jaovo.msg.model.User" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
//接收客户端传递过来的参数
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username==null || "".equals(username.trim())){
request.setAttribute("error", "用户名不能为空");//设置error属性,属性值为“用户名不能为空”
%>
<jsp:forward page="addInput.jsp"></jsp:forward>
<% }
User user=new User();
user.setUsername(username);
user.setPassword(password); UserDaoImpl userDao=new UserDaoImpl();
try{
userDao.add(user);
%> 用户注册成功!<br>
<a href="http://www.baidu.com">百度</a>
<a href="addInput.jsp">继续添加</a><br>
<a href="list.jsp">用户列表</a>
<%
}catch(UserException e){
%>
<h2 style="color:red ; font-size:50px">发生错误:<%=e.getMessage() %></h2>
<%
}
%>
</html>

/*list.jsp*/

 <%@page import="com.jaovo.msg.model.User"%>
<%@page import="java.util.List"%>
<%@page import="com.jaovo.msg.dao.UserDaoImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户展示界面</title>
</head>
<%
UserDaoImpl userDao=new UserDaoImpl();
List<User> users=userDao.load();
%>
<body>
<table align="center" border="1" width="500">
<tr>
<td>用户编号</td>
<td>用户名称</td>
<td>用户密码</td>
</tr>
<%
for( User user : users){
%>
<tr>
<td><%=user.getId() %></td>
<td><%=user.getUsername() %></td>
<td><%=user.getPassword() %></td>
<td><a href="delete.jsp ? id="<%=user.getId() %>" >删除</a></td> </tr>
<%
}
%>
</table>
</body>
</html>

/*loginInput.jsp*/

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户登录</title>
</head>
<body>
<%=request.getAttribute("error") %>
<form action="login.jsp" method="get">
<h2 style="color:blue ; font-size:30px">用户登录</h2> <tr>
<td>用户名:</td>
<td>
<input type="text" name="username" />
</td>
</tr><br>
<tr>
<td>密码:</td>
<td>
<input type="password" name="password"/>
</td>
</tr><br>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="登录" />
<input type="reset" name="重置" />
</td>
</tr>
</body>
</html>

/*login.jsp*/

 <%@page import="com.jaovo.msg.Util.UserException"%>
<%@page import="com.jaovo.msg.dao.UserDaoImpl" %>
<%@page import="com.jaovo.msg.model.User" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
//接收客户端传递过来的参数
UserDaoImpl userDao=new UserDaoImpl();
User user=new User();
String username=request.getParameter("username");
String password=request.getParameter("password");
user=userDao.load(username);
if(username==null || "".equals(username.trim())){
request.setAttribute("error", "请输入用户名");//设置error属性,属性值为“请输入用户名”
%>
<jsp:forward page="loginInput.jsp"></jsp:forward>
<%
}
if(user==null||(user!=null&&!user.getPassword().contentEquals(password)))
{
request.setAttribute("error", "输入信息错误");
%>
<jsp:forward page="loginInput.jsp"></jsp:forward>
<%
}
%>
用户登录成功!<br>
</html>

3.运行结果截图

4.列出你对这门课的希望和自己的目标,并具体列出你计划每周花多少时间在这门课上。

希望通过这门课的学习,真正和老师建立“教练与学员”的关系,自己要主动学习,多加练习,在动态网站这一领域打好基础,熟练掌握其一般要用到的语言,在实现功能的基础上更进一步,实现界面的美观,让用户使用便捷、舒适。

计划每周周一至周五抽出五小时左右,周末尽可能更多的时间来练习,以求掌握、领会更精湛的技术,提高编程能力。

最新文章

  1. archlinux中c语言的rpc编程
  2. redis+Keepalived实现Redis主从复制
  3. iOS中的时间和日期
  4. POJ3686 The Windy&#39;s(最小费用最大流)
  5. 使用maven来管理您的java项目
  6. mmo设计
  7. Socket 学习入门
  8. poj1556
  9. QF——iOS中数据持久化的几种方式
  10. 浅谈TCP优化(转)
  11. 收集一些工作中常用的经典SQL语句
  12. 完善tab页面定位
  13. Android 7.0 新特性
  14. PureComponent的作用及一些使用陷阱
  15. Android高级控件(上)
  16. Code Signal_练习题_growingPlant
  17. 《Migrating to Cloud-Native Application Architectures》学习笔记之Chapter 2. Changes Needed 原
  18. (笔记)CANOpen移植(CanFestival移植)
  19. HTML5的表单所有type类型
  20. centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课

热门文章

  1. 常见DOS操作
  2. linux 操作 I/O 端口
  3. Kakuro Extension HDU - 3338 (Dinic)
  4. koa2入门--01.ES6简单复习、koa2安装以及例子
  5. CentOS7.6部署k8s环境
  6. python简单小程序
  7. 一种HTML table合并单元格的思路
  8. Ceph 之RGW Pub-Sub Module
  9. Serverless 实战 —— Funcraft + OSS + ROS 进行 CI/CD
  10. 泛型的运用(用于查询数据后DataTable转实体类)