smbms项目(超市订单管理系统)#javaweb

目录

1.项目搭建准备工作

2.登录功能实现 

3.登陆功能优化

注销功能

登录拦截优化

 4.密码修改

优化密码修改使用Ajax

5.用户管理实现 

1.获取用户数量

2.获取用户列表

3.获取角色列表

4.用户显示的servlet

6.增删改查


数据库 

  • 项目如何搭建
    考虑使用不使用 Maven?依赖,jar

1.项目搭建准备工作

  • 1.搭建一个maven web 项目
  • 2.配置Tomcat
  • 3.测试项目是否能够跑起来
  • 4.导入项目中需要的jar包:jsp,Servlet,mysql驱动,jstl,standard…

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example</groupId>
  <artifactId>smbms</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>

<dependencies>
<!--  junit-->
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
  </dependency>
<!--  servlet jsp-->
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
  </dependency>
<!--  JSP-->
  <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.3.3</version>
  </dependency>
<!--  JSTL表达式的依赖-->
  <dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>1.2</version>
  </dependency>
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
  </dependency>
  <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.76</version>
  </dependency>

<!--mysql驱动-->
  <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.48</version>
  </dependency>

  <!--  standard标签库-->
  <dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
  </dependency>
</dependencies>

  <!--静态资源导出问题    -->
  <build>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
    </resources>
  </build>
</project>
  • 5.创建项目包结构

  • 6. 编写实体类

        ROM映射:表-类映射

Bill.java

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

    private String providerName;//供应商名称

//getset
}

Provider.java

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

Role.java

package shuangma.pojo;


public class Role {

  private Integer id;//id
  private String roleCode;//角色编码
  private String roleName;//角色名称
  private Integer createdBy;//创建者
  private java.sql.Timestamp creationDate;//创建时间
  private Integer modifyBy;//更新者
  private java.sql.Timestamp modifyDate;//更新时间
//getset
}

User.java

public class User {

  private Integer id;//id
  private String userCode;//用户编码
  private String userName;//用户名称
  private String userPassword;//用户密码
  private Integer gender;//性别
  private Date birthday;//出生日期
  private String phone;//电话
  private String address;//地址
  private Integer userRole;//用户角色
  private Integer createdBy;//创建者
  private Date creationDate;//创建时间
  private Integer 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 void setAge(Integer age) {
    this.age = age;
  }
//getset
}
  • 7.编写基础公共类
    • 7.1.数据库配置文件

db.properties

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/smbms?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false
username=root
password=000000
  • 7.2.编写数据库的公共类

BaseDao.java

package shuangma.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 {
        //通过类加载器读取对应的资源
        InputStream is = BaseDao.class.getClassLoader().getResourceAsStream("db.properties");
        Properties properties = new 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 ge
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值