• JSP 用户表单的简单实现


     1 <%@ page language="java" contentType="text/html; charset=utf-8"
     2     pageEncoding="utf-8"    import="java.util.*" %>
     3 <%@ page import="java.sql.*" %>
     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>用户表单</title>
     9 </head>
    10 <body>
    11 <center>
    12     <form action="SetPropertyDemo.jsp" method="post">
    13         <table>
    14             <tr>
    15                 <td colspan="2">用户表单</td>
    16             </tr>
    17             <tr>
    18                 <td>用户名:</td>
    19                 <td><input type="text" name="username"></td>
    20             </tr>
    21             <tr>
    22                 <td>&nbsp;&nbsp;码:</td>
    23                 <td><input type="password" name="userpassword"></td>
    24             </tr>
    25             <tr>
    26                 <td colspan="2">
    27                 <input type="submit" name="提交">
    28                 <input type="reset" name="重置">
    29             </tr>
    30         </table>
    31     </form>
    32 </center>
    33 </body>
    34 </html>

    这个表单简单实现了用户名+密码的参数传递。

    在该页提交了用户名和密码之后,会跳转到另一个页面SetPropertyDemo.jsp,输出提交的用户信息。

    SetPropertyDemo.jsp的代码如下:

     1 <%@ page language="java" contentType="text/html; charset=utf-8"
     2     pageEncoding="utf-8"    import="java.util.*" %>
     3 <%@ page import="java.sql.*" %>
     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>设置JavaBean属性</title>
     9 </head>
    10 <body>
    11     <jsp:useBean id="user" scope="page" class="chapter7.UserBean"></jsp:useBean>
    12     <jsp:setProperty property="*" name="user"/>
    13     <%
    14         out.println("用户名:"+user.getUsername()+"<br/>");
    15         out.println("用户密码:"+user.getPassword());
    16     %>
    17 </body>
    18 </html>
  • 相关阅读:
    Python(九)之网络编程
    Bat命令
    Python(八)之函数
    RedHat下安装Python开发环境
    Redhat6.5安装DB2 Express-C版本
    Linux下字符集的安装
    Linux命令之stty
    AIX查看CPU、内存等信息
    stopManagedWebLogic.sh强制关闭Managed Server
    Keepalived + Nginx + Tomcat 的高可用负载均衡架构搭建
  • 原文地址:https://www.cnblogs.com/xingzhui/p/5745092.html
Copyright © 2020-2023  润新知