zoukankan      html  css  js  c++  java
  • application和javaBean练习

    编写一个jsp程序,实现将用户信息保存在application对象的用户注册

     1 package com.sp.test;
     2 
     3 public class User {
     4 
     5     private String usename;
     6     private String password;
     7     
     8     public String getUsename() {
     9         return usename;
    10     }
    11     public void setUsename(String usename) {
    12         this.usename = usename;
    13     }
    14     public String getPassword() {
    15         return password;
    16     }
    17     public void setPassword(String password) {
    18         this.password = password;
    19     }
    20     public User(String usename, String password) {
    21         super();
    22         this.usename = usename;
    23         this.password = password;
    24     }
    25     
    26     
    27 }
     1 <%@page import="com.sp.test.User"%>
     2 <%@ page language="java" contentType="text/html; charset=UTF-8"
     3     pageEncoding="UTF-8"%>
     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 <%
    12 Object obj = application.getAttribute("use");
    13 if(obj == null){
    14     User u = new User("张三","123");
    15     application.setAttribute("use", u);
    16     obj = u;    
    17 }
    18 User us = (User)obj;
    19 //输出用户信息
    20 out.println("用户名:" + us.getUsename() + "<br>密码:" + us.getPassword());
    21 %>
    22 </body>
    23 </html>

  • 相关阅读:
    MySQL用户
    python -- 中
    Python -- 上
    Zabbix导入数据库时报错
    chmod无执行权限
    编译安装Tengine
    Nginx的调度算法
    nginx--第三方模块echo
    ngx_http_headers_module
    nginx---隐藏或添加后端服务器的信息
  • 原文地址:https://www.cnblogs.com/ouyangtangfeng99/p/5631791.html
Copyright © 2011-2022 走看看