Struts2:从会话对象获取值
我有一个与Struts2课程相关的问题。 我的数据库代码是:Struts2:从会话对象获取值,struts2,Struts2,我有一个与Struts2课程相关的问题。 我的数据库代码是: public LinkedList<AddNewPatientBean> listOfCheckinPat(AddNewPatientBean patientBean) { LinkedList<AddNewPatientBean> listOfCheckin = new LinkedList<AddNewPatientBean>(); int checkinVal = 1;
public LinkedList<AddNewPatientBean> listOfCheckinPat(AddNewPatientBean patientBean) {
LinkedList<AddNewPatientBean> listOfCheckin = new LinkedList<AddNewPatientBean>();
int checkinVal = 1;
int checkinVal1 = 1;
String selectQuery = " select * from pat_checkin where dispName=? AND ownerId=? AND checkIn=? ";
// lockValue.add(new AddNewPatientBean("1"));
System.out.println("dispname1 "+patientBean.getDispName());
System.out.println("dispname2 "+patientBean.getOwnerId());
System.out.println("dispname3 "+checkinVal);
try {
con = DBConnection.dbConn();
pStatement = con.prepareStatement(selectQuery);
pStatement.setString(1, patientBean.getDispName());
pStatement.setString(2, patientBean.getOwnerId());
pStatement.setInt(3, checkinVal);
rs = pStatement.executeQuery();
while (rs.next()) {
checkinVal1++;
listOfCheckin.add(new AddNewPatientBean(rs.getInt("checkIn_id"),rs.getInt("pat_id"),rs.getString("patName"),rs.getString("dispName"),rs.getString("ownerId"),rs.getInt("checkIn")));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
System.out.println("checked detail dao size "+listOfCheckin.size()+" RS VAL "+rs+" "+checkinVal1);
con.close();
pStatement.close();
rs.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
return listOfCheckin;
}
这个动作类:
//list
System.out.println("Owner ID is ------->>> "+ownerId);
AddNewPatientBean bean = new AddNewPatientBean(r3, ownerId,subOwnerId);
listCheckinPat = addNewPatServInter.listOfCheckinPatServ(bean);
for( AddNewPatientBean nsns : listCheckinPat) {
System.out.println("heoollmmmmm***************** "+nsns.getPatName());
System.out.println("heoollmmmmm***************** "+nsns.getId());
System.out.println("heoollmmmmm***************** "+nsns.getChkinOrchkoutVal());
session.put("waitList", listCheckinPat);
}
直到这里一切都很好。现在我想从JSP页面中的会话中获取值。
如何获取该值?您可以通过
(OGNL表达式)访问该值,您可以这样编写:
<s:iterator value='%{session.test}' >
其他财产:
<s:property value="#application.anAppAttribute" />
<s:property value="#session.aSessionAttribute" />
<s:property value="#request.aRequestAttribute" />
<s:property value="#parameters.aRequestParameter" />
您尝试了什么?取决于您想对值执行什么操作,是否显示列表?另外,为了在JSP上显示某些内容,您不必将其放在会话中,操作在请求视图(JSP)期间公开,因此只需为属性提供getter即可。有关访问此类属性的方法,请参见:
<s:property value="#application.anAppAttribute" />
<s:property value="#session.aSessionAttribute" />
<s:property value="#request.aRequestAttribute" />
<s:property value="#parameters.aRequestParameter" />