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;
}}
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;
}}
解决方案 »
- 求教各位朋友,关于spring定时器不执行的问题。
- 不知道大家jpa ,都用什么实现。
- 不知道出了什么错误啊 急
- 写一程序,将"d","b","a","c"依次存入list中,并按照abcd的顺序用迭代器输出
- spring配置的事物管理问题
- myeclipse for linux 下载地址,谁给个?
- Hibernate执行SQL发生的情况!
- 如何利用HIBERNATE取得NULL值??
- 小妹请教:我以WEBLOGIC做WEB服务器.IPLANET做目录服务器.在配置WEBLOGIC与LDAP服务连接时遇到困难,请高手指点.在线等!急
- JBuilderX+WebSphere5.1下如在JBuilder中启动WebSphere Server
- oracle中如何同时向两张有主外键关系的表中插入数据
- 问一个在jsp页面里引入java文件的路径问题
...
...
...
{
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);
}
这是一个for循环,但是我查询的过程中每一次只查询到一次for循环的值
可是我想查询到所有for循环的值
先用个对象进行接收保存,再遍历这个对象呢,不然你每次循环都要去调用这个