zoukankan      html  css  js  c++  java
  • 软件工程概论,java web项目

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

    实施Java的WEB项目需要掌握的技术如:
    面向对象分析设计思想,设计模式和框架结构,
    XML语言,网页脚本语言,数据库,应用服务器,集成开发环境
    Java语言是完全面向对象的语言,
    所以在项目设计时会有很大的帮助,在设计时应尽量舍弃以往的面向过程的设计方式。
    在分析项目业务关系的时候,应用一些UML(Unified Modeling Language)图,例如常用的用例图,类图,时序图等等,会有很大的帮助,
    在服务器和设计模式结构中会应用到自定义文件,而且在应用高级设计时也会定义自用的标签,现在流行的是用XML去定义配置,所以XML语言应该有一定掌握
    为了提高WEB项目的整体性能,提高人机交互的友好界面,网页的脚本语言是很有用处的,有的时候可以解决很大的难题或提高程序的性能和应用性
    JavaScript是一种基于对象和事件驱动并具有安全性能的脚本语言。
    使用它的目的是与HTML超文本标记语言、Java 脚本语言(Java小程序)一起实现在一个Web页面中链接多个对象,与Web客户交互作用。从而可以开发客户端的应用程序等。

    源程序:登陆界面及其功能的设计

    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();

    }
    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 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,nickname) value (?,?,?)";
    preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1, user.getUsername());
    preparedStatement.setString(2, user.getPassword());
    preparedStatement.setString(3, user.getNickname());
    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) {
    Connection connection = DBUtil.getConnection();
    //准备sql语句
    String sql = "update t_user set password = ? , nickname=? where id = ?";
    //创建语句传输对象
    PreparedStatement preparedStatement = null;
    try {
    preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1, user.getPassword());
    preparedStatement.setString(2, user.getNickname());
    preparedStatement.setInt(3, 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 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.setPassword(resultSet.getString("password"));
    user.setNickname(resultSet.getString("nickname"));
    }
    } 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) {
    // TODO Auto-generated method stub
    return null;
    }

    @Override
    public List<User> load() {
    Connection connection = DBUtil.getConnection();
    //准备sql语句
    String sql = "select * from t_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"));
    user.setNickname(resultSet.getString("nickname"));
    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 nickname;
    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 getNickname() {
    return nickname;
    }
    public void setNickname(String nickname) {
    this.nickname = nickname;
    }
    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 {
    //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/jaovo_msg";
    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();
    }
    }

    }
    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
    }

    }
    <%@ 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">
        <table align="center" border="2" 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" value="重置" />
          </td>
        </tr>
        </table>
      </form>
    </body>
    </html>

    程序运行截图:

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

    对于这门课,我想的是好好学其中的知识,独立自主完成 数据库的增删改查,独立自主完成一个小型的MIS系统,每周的话,是周一到周五每天有两个多小时在其中学习,周日 希望是能借着百度,独立学习数据库,完成一个一个的小点。

  • 相关阅读:
    2020年,初级、中级 Android 工程师可能因离职而失业吗?
    Android 后台运行白名单,优雅实现保活
    使用DataBinding还在为数据处理头疼?这篇文章帮你解决问题
    Android 7.x Toast BadTokenException处理
    2017-2020历年字节跳动Android面试真题解析(累计下载1082万次,持续更新中)
    Flutter 尺寸限制类容器总结:这可能是全网解析最全的一篇文章,没有之一!
    并行收集器
    高性能索引策略
    Innodb简介
    索引的优点
  • 原文地址:https://www.cnblogs.com/maxin123/p/7886375.html
Copyright © 2011-2022 走看看