如何在jsp页面获取所有map类型的session中的值,action中的代码如下。。。
package com.pdsu.chy.action;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionSupport;
import com.pdsu.chy.model.Manager_medicine;
import com.pdsu.chy.service.MedicineService;
@Component("find1")
@Scope("prototype")
public class PatientFindAction extends ActionSupport implements SessionAware
{
public int findtype;
private String drug;
private MedicineService medicineService;
private Map<String, Object>session;
public int length0;
public int getFindtype()
{
return findtype;
}
public void setFindtype(int findtype)
{
this.findtype = findtype;
}
public String getDrug()
{
return drug;
}
public void setDrug(String drug)
{
this.drug = drug;
}
public MedicineService getMedicineService()
{
return medicineService;
}
@Resource
public void setMedicineService(MedicineService medicineService)
{
this.medicineService = medicineService;
}
@Override
public String execute() throws Exception
{
System.out.println("查询方式:"+findtype+"查询名称:"+drug);
Manager_medicine managerMedicine =new Manager_medicine();
if(findtype==1)
{
managerMedicine.setM_factory(drug);
}
else if(findtype==2)
{
managerMedicine.setM_date(drug);
}
else if(findtype==3)
{
managerMedicine.setM_name(drug);
}
else if(findtype==4)
{
managerMedicine.setM_type(drug);
}
length0=medicineService.find(managerMedicine,findtype).size();
System.out.println("长度:"+length0);
for(Manager_medicine managerMedicine2 : medicineService.find(managerMedicine,findtype))
{
System.out.println("进入这一部:"+managerMedicine2.getM_name()
+managerMedicine2.getM_factory()+managerMedicine2.getM_date()+managerMedicine2.getM_price()
+managerMedicine2.getM_type());
session.put("m_name", managerMedicine2.getM_name());
session.put("m_factory", managerMedicine2.getM_factory());
session.put("m_price", managerMedicine2.getM_price());
session.put("m_date", managerMedicine2.getM_date());
session.put("m_prange", managerMedicine2.getM_prange());
session.put("m_type", managerMedicine2.getM_type());
session.put("length0", length0);
}
return "Patient_Success";
}
public void setSession(Map<String, Object> session)
{
this.session=session;
}
}
------解决方案--------------------<s:property value="#session.m_name"/>
...
...
...
------解决方案--------------------medicineService.find(managerMedicine,findtype)
先用个对象进行接收保存,再遍历这个对象呢,不然你每次循环都要去调用这个