• jsp第七周作业


    custom.java
    package com.gd.bean;
    
    public class custom {
    
        
        public int getUid() {
            return uid;
        }
        public void setUid(int uid) {
            this.uid = uid;
        }
        public String getUname() {
            return uname;
        }
        public void setUname(String uname) {
            this.uname = uname;
        }
        public int getUpwd() {
            return upwd;
        }
        public void setUpwd(int upwd) {
            this.upwd = upwd;
        }
        private String uname;
        
        private int upwd;
        private int uid;
        public custom(int uid,int upwd,String uname){
            super();
            this.uid = uid;
            this.upwd = upwd;
            this.uname = uname;
        }
        
        
    
    }
    
    
    package com.gd.dao;
    
    
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    
    import com.gd.bean.custom;
    
    customDao.java
    
    public class customDao {
    
        java.sql.Connection con=null;
        java.sql.Statement sql;
        ResultSet rs;
        public void addCustom(custom s){
            try{
                Class.forName("com.mysql.jdbc.Driver");
                con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "root");
                
                String sql="insert into save values(???)";
                PreparedStatement pw=con.prepareStatement(sql);
                pw.setInt(1, s.getUid());
                pw.setString(2, s.getUname());
                pw.setInt(3, s.getUpwd());
                pw.execute();
            }
            catch(Exception e){
                e.printStackTrace();
            }
            
        }
    
    }
    
    login.jsp
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>register</title>
    <style type="text/css" ></style>
    </head>
    <body>
     
    <form action="success1.jsp" method="post">
        编号:<input type="text" name="uid"><br>
        用户名:<input type="text" name="uname"><br>
        密   码:<input type="password" name="upwd"><br>
        
        <input type="submit" value="提交">
    </form>
         
    </body>
    </html>
    success1.jsp
    <%@ page contentType="text/html" %>
    <%@ page pageEncoding="utf-8" %>
    <%@ page import="com.gd.bean.custom" %>
    <%@ page language="java" import="com.gd.dao.customDao" %>
    <%@ page language="java" import="java.util.*"%>
    
    <html>
    <body bgcolor=cyan>
    <p style="font-family:黑体;font-size:36;color:bule">
    <%        
            custom s=new custom();
            int id=Integer.paseInt(request.getParameter("uid"));
            s.setUid(id);
            String uname=request.getParameter("uname");
            s.setUname(uname);
            int upwd=Integer.paseInt(request.getParameter("upwd"));
            s.setUpwd(upwd);
            customDao ss=new customDao();
            ss.addcustom(s);
     %>
             编号: <%=id %><br/>
              用户名 : <%=uname %><br/>
                密码  : <%=upwd %>
    </body>
    </html>

  • 相关阅读:
    利用读写锁实现缓存系统
    POJ 1338 Ugly Numbers
    copy算法
    它们的定义iOS双击Home截图按键开关
    以正能量的点!!!
    该公路项目
    ArcSDE当关系查询ArcMap与REST查询结果不一致问题的解决
    【OpenCV新手教程第14】OpenCVHough变换:霍夫变换线,霍夫变换圆汇编
    为了树莓派IIraspberrypi安装emacs+ecb+cedet+session+color-theme+cscope+linum
    事件总线帧---Otto
  • 原文地址:https://www.cnblogs.com/108-com/p/14672180.html
Copyright © 2020-2023  润新知