java web用户登录 注册 入门

前期准备:在这里插入图片描述
用户的实体类:

package cn.javabs.entity;

/**
 *  entity 实体包
 *  User 实体类
 *  实体: 实实在在的个体
 */
public class User {
   
    private int id;
    private  String username;
    private  String password;
//  按快键 alt + insert 选择get和set方法
    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;
    }
}

注册的页面:在这里插入图片描述
index.jsp

<%--
  Created by IntelliJ IDEA.
  User: love
  Date: 2020/1/16
  Time: 12:23
  To change this template use File | Settings | File Templates.
--%>
<%--                      charset 字符集--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>

    <title>用户登录</title>
  </head>
  <body>
  <a href="login.jsp">已有账号,请移步...</a>
    <center>

<%--      form  形成   action 作为 pageContext 页面上下文 request 请求 contextPath 上下文路径  method 方法 post 发布,邮寄--%>
      <form action="${pageContext.request.contextPath}/userServlet" method="post">
<%--        table 表格  border 边界 1像素  width 宽 438 像素--%>
        <table border="1px" width="438px">
<%--    tr 行      align 对齐  center 中心--%>
          <tr align="center">
<%--            td 表的单元--%>
            <td>账号</td>
            <td>
<%--                input 输入  type 类型  name 名字--%>
              <input type="text" name="username">
            </td>
          </tr>
          <tr align="center">
            <td>密码</td>
            <td>
              <input type="password" name="password">
            </td>
          </tr>
          
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值