我有一个包含用户信息的数据库。当用户登录时,我在会话中注册了用户,如下所示:
ActionContext.getContext().getSession().put("loggedUser", user);
我想在我的 jsp 页面中获取用户的信息,以便用这些信息填充 struts2 文本字段。我尝试使用以下代码,但它不起作用:
<%@page import="java.util.Map"%>
<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="UbiMail.*" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
User user = (User) ActionContext.getContext().getSession().get("LoggedUser");
%>
<html>
<head>
</head>
<body>
<s:form method="POST" action="UpdateAction">
<s:actionerror/>
<s:textfield name="uname" label="Username" value="#session.LoggedUser.getUsername"/>
<s:property value="#session.LoggedUser.getUsername()"/>
<s:password name="password" label="Password"/>
<s:password name="cPassword" label="Confirm password"/>
<s:textfield name="fname" label="First name" value="#session.loggeduser.getFname()"/>
<s:textfield name="lname" label="Last name" value="#session.loggeduser.getLname()"/>
<s:textfield name="popServer" label="POP server" value="#session.loggeduser.getPopServer()"/>
<s:textfield name="popUsername" label="POP username" value="#session.loggeduser.getPopUsername()"/>
<s:password name="popPassword" label="POP password"/>
<s:textfield name="mobilePhone" label="Mobile phone" value="#session.loggeduser.getMobilePhone()"/>
<s:textfield name="filter" label="Notification filter" value="#session.loggeduser.getSms()"/>
<s:checkbox name="sms" label="Enable SMS notification"/>
<s:submit value="Update"/>
</s:form>
</body>
我需要你的帮助。