Use JavaBean in JSP instead of session

zhaozj2021-02-12  153

Using JAVABEAN in JSP instead of session, I don't like Session when I write a chat room with JSP, huh, in fact, when I use session to save the user login information, I have encountered a problem, I have no way, and later use JavaBean Instead of session, I feel is not bad, and good things are of course everyone to share. The code of javabean is as follows: package qqjspchat; public class userinfo {string username = null; string usersex = null; int usrLevel = 0; // class constructor public userinfo () {} // Put into the username PUBLIC VOID PUTUSERNAME (THISUSERNAME = Username;} // Get username PUBLIC STRING GETUSERNAME () {Return this.username;} // Add user gender Method PUBLIC VOID PUTUSERSEX (String UserSex) {this.userSex = UserSex;} // Get user gender method PUBLIC STRING GETUSERSEX () {Return this.usersEx;} // Published in user-level method PUBLIC VOID PUTUSERLEVEL (int Userlevel) ) {this.userLevel = Userlevel;} // Get user-level method PUBLIC INT getUserlevel () {Return this.userlevel;} The method applied in JSP is as follows: uses bean to save user information uinfo.putusername (username); uinfo.putusersex; uinfo.putuserlevel (userlevel); when extracting information, in turn, Remove UserNameString UserName = uinfo.getUsername (); ok, huh, huh.

转载请注明原文地址:https://www.9cbs.com/read-6413.html

New Post(0)