JSP第七周作业

 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 
 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 5 <html>
 6 <head>
 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 8 <title>Insert title here</title>
 9 <style type="text/css">
10 body {
11     background-color: azure;
12 }
13 
14 form {
15     position: fixed;
16     top: 250px;
17     left: 650px;
18     background-color: #ADD8E6;
19     border-radius: 5px;
20 }
21 
22 div {
23     font-size: 22px;
24     margin-top: 20px;
25     padding-left: 40px;
26 }
27 
28 input {
29     width: 200px;
30     height: 20px;
31     border-radius: 5px;
32 }
33 
34 #tj {
35     width: 80px;
36     height: 30px;
37     margin-left: 140px;
38     border-radius: 5px;
39     font-size: 16px;
40     margin-bottom: 20px;
41 }
42 </style>
43 
44 </head>
45 <body>
46     <form action="/school/panduanreg.jsp" method="post">
47         <div>
48             账 号:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="username">
49         </div>
50         <div>
51             密 码:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="password">
52         </div>
53 
54         <div>
55             <input type="submit" id="tj" value="注册">
56         </div>
57     </form>
58 
59 </body>
60 <script type="text/javascript">
61 
62 </script>
63 </html>
package com;

public class Stu {
    private int sid;
    private String uname;
    private String upwd;
    //访问器
    public int getSid() {
        return sid;
    }
    public void setSid(int sid) {
        this.sid = sid;
    }
    public String getUname() {
        return uname;
    }
    public void setUname(String uname) {
        this.uname = uname;
    }
    public String getUpwd() {
        return upwd;
    }
    public void setUpwd(String upwd) {
        this.upwd = upwd;
    }
    //构造器
    public Stu(int sid, String uname, String upwd) {
        super();
        this.sid = sid;
        this.uname = uname;
        this.upwd = upwd;
    }
    public Stu() {
        super();
    }
    
    
    
    
    

}
 1 <%@page import="com.Stu"%>
 2 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 3 <%
 4     Stu s = new Stu();
 5     int id = Integer.parseInt(request.getParameter("sid"));
 6     s.setSid(id);
 7     String uname = request.getParameter("uname");
 8     s.setUname(uname);
 9     String upwd = request.getParameter("upwd");
10     s.setUpwd(upwd);
11     
12     StuDao sd=new StuDao();
13     if(sd.addStu(s)>0){
14         //跳转注册成功页面 
15     }else{
16         //错误页面 
17     }
18    %>

 

posted @ 2021-04-15 16:31  刘显栋  阅读(48)  评论(0编辑  收藏  举报