一、网站系统开发需要掌握的技术:
1. 网页上要显示内容,需要学学HTML,比如这个页面,有文字,有图片。
2.光有文字还不行,还要考虑不同的颜色,布局,排版,如图做出这样页面效果,要学学基本的CSS
3. 有一些交互,比如修改了代码可以实时看到效果,得掌握Javascript
4. 现在网站有1000多张页面,不可能做1000张html呀,所以这些都需要维护在数据库里面,那就学一个简单的MySQL
5. 现在一共有55张表。。。。 怎么维护他们之间的关系~ 彼此如何依赖,外键如何关联,这个需要学习表关系的相关知识
6. 有了数据库,也有了表,那么如何从这些表里取数据呢? 我用的是JAVA技术栈,那么就需要用到JDBC
7. 为了使用JDBC不是需要Java基础吗? 为了仅仅满足JDBC的运行,需要如下JAVA基础:
面向对象,变量 操作符 控制流程,数字与字符串,异常处理,集合
8. 这样JDBC就可以取出数据了,那么取出来之后怎么显示在HTML上呢? 需要用到JSP
9. 为了JSP可以运行,需要一个Servlet容器,TOMCAT,简单用用就可以了
10. 可是TOMCAT总不能在自己机器上跑嘛,要放在公网上,运行,其他人才看得到呀,所以需要掌握如何在LINUX里部署Tomcat
11. 那么挂在公网上的Linux自己怎么弄呢? 我也弄不来,我是在阿里云租的LINUX云服务器
12. 随着网站提供的功能越来越多,光用JSP开发太慢了,而且难以维护,这个时候就用到了Struts 加快开发效率
13. JDBC也有点难以维护了,那么就换成了Hibernate
14. 为了让Struts和Hibernate更好的整合在一起,那还得学学Spring以及这3个的整合
15. Struts常常有漏洞产生,所以还得时常打补丁
16. 为了更好的讲解知识点,录了教学视频,所以还得会录屏软件。。。
17. 这些视频放在youku不太好,会有广告,放在云盘也不好,会被莫名其妙举报而关闭,所以还是放在自己网站吧。 那么为了播放,还的学会html5的播放方式
18. 随着访问的人数增多,看视频的人有个3,4个人同时看的时候,视频播放就卡成狗了,所以为了播放顺利,得把视频放在OSS上面去
19. 可是视频也多呢,一个一个得手动上传多麻烦,那就得调用阿里云的API,用Java帮你自动上传
20.还有些和开发技术无关的,也是需要掌握的,比如域名,要自己去选购一个,也是在阿里云买的, 以前叫域名里包含java这个商标,害怕被oracle拿回去,就改了。
21. 光有域名还不行,当服务器是在国内的时候,是需要备案的
课堂测试的源程序代码:
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 int load(String username,String password) ;
public List<User> load();
}
package com.jaovo.msg.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.jaovo.msg.Util.UserException;
import com.jaovo.msg.Util.DBUtil;
import com.jaovo.msg.model.User;
public class UserDaoImpl implements IUserDao{
@Override
public void add(User user) {
Connection connection=DBUtil.getConnection();
String sql="select count(*) from t_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) {
throw new UserException("登陆成功") ;
}
}
sql="insert into t_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 t_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) {
// TODO Auto-generated method stub
Connection connection=DBUtil.getConnection();
String sql="update t_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();
String sql="select * from t_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.setUsername(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 int load(String username,String password) {
/*Connection connection=DBUtil.getConnection();
String sql="select * from t_user where username = ?";
Statement statement=null;
ResultSet resultSet=null;
int boo=1;
try {
statement=connection.createStatement();
resultSet=preparedStatement.executeQuery();
while(resultSet.next()) {
if(password.equals(resultSet.getString(2))) {
boo=1;
}
else boo=2;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(resultSet);
DBUtil.close(preparedStatement);
DBUtil.close(connection);
}
return boo;*/
int n=0;
try {
Class.forName("com.mysql.jdbc.Driver");
try {
//String string="ji";
String url="select * from t_user where username = ? ";
Connection connection=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/jaovo_msg","root", "root");
PreparedStatement preparedStatement=connection.prepareStatement(url);
preparedStatement.setString(1, username);
ResultSet resultSet=preparedStatement.executeQuery();
//String string="hava";
while(resultSet.next()) {
//System.out.println(resultSet.getInt(1));
//System.out.println(resultSet.getString(2));
if(username.equals(resultSet.getString(2))&&password.equals(resultSet.getString(3))) n=1;
else n=2;
}
resultSet.close();
preparedStatement.close();
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return n;
}
@Override
public List<User> load() {
Connection connection=DBUtil.getConnection();
String sql="select * from t_user where id = ?";
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
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;
}
}
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;
}
}
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 { 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/jaovo_msg"; Connection connection=null; try { 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(); } } }
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 } }
课堂测试未按时完成原因:
数据库的链接不熟,增删改查不熟,jsp页面也不熟。
列出你对这门课的希望和自己的目标,并具体列出你计划每周花多少时间在这门课上:
我希望我能掌握开发网站的技术,计划花四分之一的时间。