栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

IDEA开发javaweb应用历程

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

IDEA开发javaweb应用历程

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录
  • 前言
  • 一、smbms系统是什么?
  • 二、项目搭建
    • 1.搭建一个mavenweb项目
    • 3.测试项目能够跑起来
    • 4.导入项目需要的jar包
    • 6.编写实体类
    • 7.编写基础公共类
    • 8.导入静态资源
  • 三、项目实际开发过程


前言

随着对java学习的深入,已经学习到了javaweb引用开发,处于对此项开发技术的兴趣,决定来自己动手实现一个超市管理系统.对于此项工程也感兴趣的同学可以参考以下过程自己来动手实践.
开发此项目需要建立数据库和获取相关静态资源,有兴趣的同学课课私信我免费获取数据库sql文件以及前端静态资源


提示:以下是本篇文章正文内容,下面案例可供参考

一、smbms系统是什么?

smbms系统是一个超市管理系统.具体功能等待开发实际展示,

二、项目搭建 1.搭建一个mavenweb项目


3.测试项目能够跑起来

4.导入项目需要的jar包

只有idea左侧栏中的Exterral Libraries中出现了你导入的jar包才能确定导入成功


## 5.创建项目包结构 ![在这里插入图片描述](https://img-blog.csdnimg.cn/92b17b286120449993011a6588ca4811.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAemhhbmdwdXB1cHVwdQ==,size_10,color_FFFFFF,t_70,g_se,x_16#pic_center) 6.编写实体类

代码如下(User类):

package com.zhang.pogo;


import java.util.Date;

public class User {

  private long id;//id
  private String userCode;                 //用户编码
  private String userName;//用户名称
  private String userPassword;//用户密码
  private long gender;//性别
  private java.sql.Date birthday;//出生时期
  private String phone;//电话
  private String address;//地址
  private long userRole;//用户角色
  private long createdBy;//创建者
  private Date creationDate;//创建时间
  private long modifyBy;//更新者
  private Date modifyDate;//更新时间

  private Integer age;//年龄
  private String userRoleName;//用户角色名称

  public Integer getAge() {
    Date date = new Date();
    Integer age=date.getYear()-birthday.getYear();
    return age;
  }


  public String getUserRoleName() {
    return userRoleName;
  }

  public void setUserRoleName(String userRoleName) {
    this.userRoleName = userRoleName;
  }


  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  public String getUserCode() {
    return userCode;
  }

  public void setUserCode(String userCode) {
    this.userCode = userCode;
  }


  public String getUserName() {
    return userName;
  }

  public void setUserName(String userName) {
    this.userName = userName;
  }


  public String getUserPassword() {
    return userPassword;
  }

  public void setUserPassword(String userPassword) {
    this.userPassword = userPassword;
  }


  public long getGender() {
    return gender;
  }

  public void setGender(long gender) {
    this.gender = gender;
  }


  public java.sql.Date getBirthday() {
    return birthday;
  }

  public void setBirthday(java.sql.Date birthday) {
    this.birthday = birthday;
  }


  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }


  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }


  public long getUserRole() {
    return userRole;
  }

  public void setUserRole(long userRole) {
    this.userRole = userRole;
  }


  public long getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(long createdBy) {
    this.createdBy = createdBy;
  }


  public Date getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(java.sql.Timestamp creationDate) {
    this.creationDate = creationDate;
  }


  public long getModifyBy() {
    return modifyBy;
  }

  public void setModifyBy(long modifyBy) {
    this.modifyBy = modifyBy;
  }


  public Date getModifyDate() {
    return modifyDate;
  }

  public void setModifyDate(java.sql.Timestamp modifyDate) {
    this.modifyDate = modifyDate;
  }

}

代码如下(Role类):
package com.zhang.pogo;

import java.util.Date;

public class Role {

  private long id;//id
  private String roleCode;//角色编码
  private String roleName;//角色名称
  private long createdBy;//创建者
  private Date creationDate;//创建时间
  private long modifyBy;//更新者
  private Date modifyDate;//更新时间


  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  public String getRoleCode() {
    return roleCode;
  }

  public void setRoleCode(String roleCode) {
    this.roleCode = roleCode;
  }


  public String getRoleName() {
    return roleName;
  }

  public void setRoleName(String roleName) {
    this.roleName = roleName;
  }


  public long getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(long createdBy) {
    this.createdBy = createdBy;
  }


  public Date getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(java.sql.Timestamp creationDate) {
    this.creationDate = creationDate;
  }


  public long getModifyBy() {
    return modifyBy;
  }

  public void setModifyBy(long modifyBy) {
    this.modifyBy = modifyBy;
  }


  public Date getModifyDate() {
    return modifyDate;
  }

  public void setModifyDate(java.sql.Timestamp modifyDate) {
    this.modifyDate = modifyDate;
  }

}

代码如下(Provider 类):
package com.zhang.pogo;


import java.util.Date;

public class Provider {

  private long id;        //id
  private String proCode;//供应商编码
  private String proName;//供应商名称
  private String proDesc;//供应商描述
  private String proContact;//供应商描述人
  private String proPhone;//供应商电话
  private String proAddress;//供应商地址
  private String proFax;//供应商传真
  private long createdBy;//创建者
  private Date creationDate;//创建时间
  private Date modifyDate;//更新时间
  private long modifyBy;//更新者




  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  public String getProCode() {
    return proCode;
  }

  public void setProCode(String proCode) {
    this.proCode = proCode;
  }


  public String getProName() {
    return proName;
  }

  public void setProName(String proName) {
    this.proname = proName;
  }


  public String getProDesc() {
    return proDesc;
  }

  public void setProDesc(String proDesc) {
    this.proDesc = proDesc;
  }


  public String getProContact() {
    return proContact;
  }

  public void setProContact(String proContact) {
    this.proContact = proContact;
  }


  public String getProPhone() {
    return proPhone;
  }

  public void setProPhone(String proPhone) {
    this.proPhone = proPhone;
  }


  public String getProAddress() {
    return proAddress;
  }

  public void setProAddress(String proAddress) {
    this.proAddress = proAddress;
  }


  public String getProFax() {
    return proFax;
  }

  public void setProFax(String proFax) {
    this.proFax = proFax;
  }


  public long getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(long createdBy) {
    this.createdBy = createdBy;
  }


  public Date getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(java.sql.Timestamp creationDate) {
    this.creationDate = creationDate;
  }


  public Date getModifyDate() {
    return modifyDate;
  }

  public void setModifyDate(java.sql.Timestamp modifyDate) {
    this.modifyDate = modifyDate;
  }


  public long getModifyBy() {
    return modifyBy;
  }

  public void setModifyBy(long modifyBy) {
    this.modifyBy = modifyBy;
  }

}

代码如下(Bill类):

package com.zhang.pogo;


import java.util.Date;

public class Bill {

  private long id;//id
  private String billCode;//账单编码
  private String productName;//商品名称
  private String productDesc;//商品描述
  private String productUnit;//商品单位
  private double productCount;//商品数量
  private double totalPrice;//总金额
  private long isPayment;//是否支付
  private long createdBy;//创建者
  private Date creationDate;//创建时间
  private long modifyBy;//更新者
  private Date modifyDate;//更新时间
  private long providerId;//供应商id

  private String providerName;//供应商名称


  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  public String getBillCode() {
    return billCode;
  }

  public void setBillCode(String billCode) {
    this.billCode = billCode;
  }


  public String getProductName() {
    return productName;
  }

  public void setProductName(String productName) {
    this.productName = productName;
  }


  public String getProductDesc() {
    return productDesc;
  }

  public void setProductDesc(String productDesc) {
    this.productDesc = productDesc;
  }


  public String getProductUnit() {
    return productUnit;
  }

  public void setProductUnit(String productUnit) {
    this.productUnit = productUnit;
  }


  public double getProductCount() {
    return productCount;
  }

  public void setProductCount(double productCount) {
    this.productCount = productCount;
  }


  public double getTotalPrice() {
    return totalPrice;
  }

  public void setTotalPrice(double totalPrice) {
    this.totalPrice = totalPrice;
  }


  public long getIsPayment() {
    return isPayment;
  }

  public void setIsPayment(long isPayment) {
    this.isPayment = isPayment;
  }


  public long getCreatedBy() {
    return createdBy;
  }

  public void setCreatedBy(long createdBy) {
    this.createdBy = createdBy;
  }


  public Date getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(java.sql.Timestamp creationDate) {
    this.creationDate = creationDate;
  }


  public long getModifyBy() {
    return modifyBy;
  }

  public void setModifyBy(long modifyBy) {
    this.modifyBy = modifyBy;
  }


  public Date getModifyDate() {
    return modifyDate;
  }

  public void setModifyDate(java.sql.Timestamp modifyDate) {
    this.modifyDate = modifyDate;
  }


  public long getProviderId() {
    return providerId;
  }

  public void setProviderId(long providerId) {
    this.providerId = providerId;
  }

}


7.编写基础公共类

(1)数据库配置文件
(文件)dp.properties:

driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/jdbc?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = GMT
username=root
password=xxxxxx
(1)操作数据库的公共类 代码如下(baseDao类):
package com.zhang.dao;

import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;

//操作数据库的公共类
public class baseDao {

    private static String driver;
    private static String url;
    private static String username;
    private static String password;

    //静态代码块,类加载的时候就初始化
    static {
        Properties properties = new Properties();
        //通过类加载器读取对应的资源
        InputStream is = baseDao.class.getClassLoader().getResourceAsStream("dp.properties");

        try {
            properties.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }

       driver = properties.getProperty("driver");
       url = properties.getProperty("url");
       username = properties.getProperty("username");
       password = properties.getProperty("password");
    }
    //获取数据库的连接
    public static Connection getConnection(){
        Connection connection=null;
        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url, username, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }

    //编写查询公共类
    public static ResultSet execute(Connection connection,String sql,Object[] params,ResultSet resultSet,PreparedStatement preparedStatement) throws SQLException {
       //预编译的sql,在后面直接执行就可以了
        preparedStatement = connection.prepareStatement(sql);

        for (int i = 0; i  
 (1)编写过滤器 代码如下(示例): 
package com.zhang.filter;

import javax.servlet.*;
import java.io.IOException;

public class CharacterEncodingFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding("utf-8");
        servletResponse.setCharacterEncoding("utf-8");

        filterChain.doFilter(servletRequest,servletResponse);
    }

    public void destroy() {

    }
}


8.导入静态资源


此处的静态资源由自己搜集相关资源和自主编写完成,实属不易,需要资源的可以私信我免费获取.

三、项目实际开发过程

代码如下(示例):

//开发代码会在后续过程中逐步发放

# 总结 提示:这里对文章进行总结: 例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/355107.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号