• JavaBean简单示例


    本示例说明:

      从Login.jsp中输入用户名和密码,提交,在NewFile.jsp中显示信息。

    -----

    类要放在一个包中!!!

    UserB 类文件

     1 package model;
     2 
     3 public class UserB {
     4 
     5     private String user;
     6     private String pwd;
     7 
     8     public String getUser() {
     9         return user;
    10     }
    11 
    12     public void setUser(String user) {
    13         this.user = user;
    14     }
    15 
    16     public String getPwd() {
    17         return pwd;
    18     }
    19 
    20     public void setPwd(String pwd) {
    21         this.pwd = pwd;
    22     }
    23 }

     Login.jsp

     1 <%@ page language="java" contentType="text/html; charset=utf-8"
     2     pageEncoding="utf-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     7 <title>Insert title here</title>
     8 </head>
     9 <body>
    10     <form name="f1" method="post" action="NewFile.jsp">
    11         user name:<input name="user" type="text"></input><br />
    12         user password:<input name="pwd" type="password"></input></br />
    13         <input type="submit" name="ok" value="OK"></input>
    14     </form>
    15 </body>
    16 </html>

    NewFile.jsp

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <html>
     4 <head>
     5 <title>Insert title here</title>
     6 </head>
     7 <body>
     8 <jsp:useBean id="user" class="model.UserB" scope="request"/>
     9 <jsp:setProperty property="*" name="user" />
    10 用户名:<jsp:getProperty property="user" name="user"/><br/>
    11 密码:<jsp:getProperty property="pwd" name="user"/>
    12 </body>
    13 </html>
  • 相关阅读:
    tfrecord汇总
    python2中的编码的问题
    python multiprocessing的问题
    转载,ubuntu shell ~/.bashrc /etc/bash.bashrc
    singleton模式 Python
    目标检测 tensorflow(预训练模型)
    functools.partial 小记
    python 踩坑小计 virtualenv-site-packages
    python3.6 _tkinter module问题 python源码重新编译
    windows核心编程之网络编程入门篇
  • 原文地址:https://www.cnblogs.com/A--Q/p/5948921.html
Copyright © 2020-2023  润新知