1

我有一个与 Struts2 会话有关的问题。我的数据库代码是:

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;
}

Bean Class 代码构造函数:

public AddNewPatientBean(int checkin_id, int id, String patName, String dispName, String usermail, int chkinOrchkoutVal) {
    super();
    this.checkin_id = checkin_id;
    this.id = id;
    this.patName = patName;
    this.dispName = dispName;
    this.useremail = usermail;
    this.chkinOrchkoutVal = chkinOrchkoutVal;
}

这是动作类:

//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 页面中的会话中获取值。我怎样才能获得价值?

4

2 回答 2

1

你可以这样写:

<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" /> 
于 2012-11-30T15:31:50.593 回答
1

您可以作为<s:property value='#session.waitList'/>(OGNL 表达式)访问它

于 2012-11-30T15:09:17.107 回答