1.将user对象存入session
request.getSession().setAttribute("user", userSession);
2.User类
public class User {
private String userId;
private String userName;
private String userPassword;
private String userEmail;
private String userPhoto;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword == null ? null : userPassword.trim();
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail == null ? null : userEmail.trim();
}
public String getUserPhoto() {
return userPhoto;
}
public void setUserPhoto(String userPhoto) {
this.userPhoto = userPhoto == null ? null : userPhoto.trim();
}
}
3.jsp页面通过JSTL表达式获取 (
1.确保引入了JSTL所需jar包;
2.jsp页面引入jstl表达式 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>)
<td>${sessionScope.user.getUserId()}</td>
<td>${sessionScope.user.getUserName()}</td>
<td>${sessionScope.user.getUserEmail()}</td>
标签:String,userPassword,userId,JSTL,session,jsp,userPhoto,null,public From: https://blog.51cto.com/u_15912510/5937844