• JSP第七周作业


    用户表:  uid (主键,自动增长)   uname  upwd
    使用分层实现注册。(必做)
    使用分层实现登录。(选做)
    index.jsp
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
        <form name="form1" method="post" action="control.jsp" >
            <table>
            <tr>    
                <td>编号:</td>
                    <td> <input type="text" name="sid" id="userName"  ></td>
                </tr>
                <tr>    
                    <td>用户名:</td>
                    <td> <input type="text" name="uname" id="userName"  ></td>
                </tr>
                <tr>    
                     <td>输入登录密码:</td>
                    <td><input type="password" name="upwd" id="pwd"></td>
                </tr>
                
                <tr>    
                    <td colspan="2"><input type="submit" value="注册"></td>
                </tr>
            </table>
        </form>
      </body>
    </html>

    control.jsp

    <%@page import="com.gd.dao.StuDao"%>
    <%@page import="com.gd.bean.Stu"%>
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
        Stu s = new Stu();
        int id = Integer.parseInt(request.getParameter("sid"));
        s.setSid(id);
        String uname = request.getParameter("uname");
        s.setUname(uname);
        String upwd = request.getParameter("upwd");
        s.setUpwd(upwd);
        
        StuDao sd=new StuDao();
        if(sd.addStu(s)>0){
            //跳转注册成功页面 
        }else{
            //错误页面 
        }
        
        
        
    %>
  • 相关阅读:
    GDI+常用操作、入门解析
    实用SQL语句大全
    SQL语句全解析
    ASP.NET MVC 浅析
    C#版文件分割器
    转一个orbitpanel GIS
    怎么给listbox 的item 添加动画1? GIS
    怎么给listbox 的item 添加动画? GIS
    关于查找可视树的一点问题 GIS
    判断gridview 滑动到最右端 GIS
  • 原文地址:https://www.cnblogs.com/kukudihua/p/14827793.html
Copyright © 2020-2023  润新知