SSM 把数据发送到jsp页面中和绑定下拉框效果

3 篇文章 0 订阅
1 篇文章 0 订阅

效果:
这里写图片描述

1.把数据查询出来(下面是mybatis-plus的单表查询)

EntityWrapper<BasPatientstype> EWBasPatientstype = new EntityWrapper<BasPatientstype>();
EWBasPatientstype.eq("delete_flag", 0);//条件
List<BasPatientstype> listBasPatientstype = basPatientstypeService.selectList(EWBasPatientstype);

2.把查询出来的数据存放到Map中

Map<String, Object> map = new HashMap<String, Object>();
//查询病人类型
EntityWrapper<BasPatientstype> EWBasPatientstype = new EntityWrapper<BasPatientstype>();
EWBasPatientstype.eq("delete_flag", 0);//条件
List<BasPatientstype> listBasPatientstype = basPatientstypeService.selectList(EWBasPatientstype);
map.put("listBasPatientstype", listBasPatientstype);

3、把Map集合存放到ModelAndView中返回jsp页面

/**
* 添加病人挂号数据准备
* @author lichenglong
* @return 
* @date 2017年10月30日 上午11:10:32
*/
@ResponseBody
@RequestMapping("/findDataPreparation")
public ModelAndView findDataPreparation(){
  //返回新的ModelAndView
  ModelAndView ma = new ModelAndView(); 
  Map<String, Object> map = new HashMap<String, Object>();
  //查询病人类型
  EntityWrapper<BasPatientstype> EWBasPatientstype = new EntityWrapper<BasPatientstype>();
  EWBasPatientstype.eq("delete_flag", 0);//条件
  List<BasPatientstype> listBasPatientstype = basPatientstypeService.selectList(EWBasPatientstype);
  map.put("listBasPatientstype", listBasPatientstype);
  ma.addAllObjects(map);//返回数据
  ma.setViewName("/assets/outpatientCharges/registrationFee/addRegistrationFee");//跳转链接
  return ma;
}

4.jsp代码

<select id="lunch" name="bookTypeId" class="selectpicker" data-live-search="true"  >
   <option value="">请选择</option>
   <c:forEach items="${listBasPatientstype }" var="data">
       <option value="${data.id }">${data.patientstype }</option>
   </c:forEach>
</select>
  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值