jsp界面获取action中的参数值
1、Action请求层
DrugDiseasesForm form = (DrugDiseasesForm) actionForm;
DrugDiseasesDTO dto = new DrugDiseasesDTO();
BeanHelper.copyProperties(form, dto);
DrugDiseasesDTO drugDto = bs.queryDrugSpecification(dto);
form.setDrug(drugDto); //form中private DrugDiseasesDTO drug;
DrugDiseasesDTO drug = form.getDrug();
//通用名
String productnamecn = drug.getProductnamecn();
if(productnamecn != null && !"".equals(productnamecn)){
request.setAttribute("productnamecn", productnamecn);
}
2、DAO层@Repository(BS 层省略)
public DrugDiseasesDTO queryDrugSpecification(DrugDiseasesDTO dto){
DrugDiseasesDTO drug = null;
String sql = " select * from yaopin where 1=1 ";
ValueBeanQueryBuilder<?> vbqb = QueryFactory.createValueBeanQueryBuilder(sql, dto);
if(dto.getAke001() != null && !"".equals(dto.getAke001())) {
vbqb.append(" and ake001='" + dto.getAke001() + "'");
}
if(dto.getId() != null && !"".equals(dto.getId())){
vbqb.append(" and id='" + dto.getId() + "'");
}
List<DrugDiseasesDTO> drugList = jdbc.query(vbqb.toHQLInfo(), DrugDiseasesDTO.class);
if(drugList != null && drugList.size() > 0) {
drug = (DrugDiseasesDTO) drugList.get(0);
}
return drug;
}
3、Sturts配置
<struts-config>
<form-beans>
<form-bean name="drugDiseasesForm" type="xx.rulemanage.knowledge.rp.DrugDiseasesForm">
</form-bean>
</form-beans>
<action-mappings>
<action name="drugDiseasesForm" scope="request" parameter="method" path="/drugDiseasesAction"type="xxx.rp.DrugDiseasesAction">
<forward name="drugSpecification" path="/pages/drug.jsp"/>
</action>
</action-mappings>
</struts-config>
4、jsp 界面
<table class="manual-table">
<tbody>
<tr>
<td class="manual-name">药品名称</td>
<td class="manual-value">
<p><span>通用名称:</span>${productnamecn }</p>
<p><span>项目名称:</span>${tradename }</p>
</td>
</tr>
<tr>
<td class="manual-name">主要成份</td>
<td class="manual-value">${component }</td>
</tr>
</tbody>
</table>