zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    Codeforces Round #613 选讲
    Codeforces Round #612 选讲
    Codeforces917E
    一道题20
    LOJ#2244. 「NOI2014」起床困难综合症
    求欧拉回路
    *LOJ#2134. 「NOI2015」小园丁与老司机
    vim操作命令
    常见问题解决
    CentOS7下如何修改mysql的数据目录
  • 原文地址:https://www.cnblogs.com/108-com/p/14672180.html
Copyright © 2011-2022 走看看