springmvc传入map至前端
来源:互联网 发布:java直播系统 编辑:程序博客网 时间:2024/06/04 19:54
还是之前推荐人的那个功能,因为提交了多条件的内容到后台 然后保存至数据库,那么这些数据该如何回显呢?这里就需要使用传入map对象了 具体的ServeltImpl如下:
页面有几个表的数据 可以将每个表查询到的数据都统一放到一个map中 然后将这个map传到页面上,页面会根据map的key名进行拆分,具体的封装见下service层:
@Override
public Map<String, Object> selectSignsAndEcoupon(String id,LsBsecoupon lb) {
LsAcSignm nm = lsAcSignmMapper.selectByIdAndRtype(id);
Map<String, Object> param = new HashMap<>();
List<LsBsecoupon> lblist=lsAcRefereedMapper.getECoupons(lb);
param.put("lblist", lblist);
if(nm!=null){
//Map<String, Object> param = new HashMap<>();
List<LsAcSignd> ndlist = lsAcSigndMapper.selectLsAcSigndBySid(id);
param.put("nm", nm);
param.put("ndlist", ndlist);
return param;
}
return param;
}
这个map中有3个对象,相当于3张表里的数据都放到了这个map中,在前端的话就可以根据这里的key名来做处理 nm lblist ndlist
现在这个map中有了3个对象,然后在controller中通过model对象传到页面中 如下:
model.addAllAttributes(param);
return "common/wx/refereeView";
该param就是服务层传过来的map 调用这个addAllAttributes就可以将map传到页面中 因为本小白比较懒,页面的代码风格可能比较臃肿,很多的css都是自己写到标签中去了 打算后期在归类 总之当时是想先将功能实现出来 下面将展示前端页面的代码部分:
<div id="fathers">
<div id="context" class="context" th:if="${not #lists.isEmpty(ndlist)}" th:each="li:${ndlist}">
<div style="background:#fff;width:100%;margin-top:20px;text-align:left;height:170px;padding:10px;border-radius: 5px;">
<div id="person" style="margin-top:10px;"><span>* 推 荐 满</span><span style="font-size:30px;" class="numSub" id="numSub"> - </span><input style="width:150px;text-align:center;border-radius:5px;margin-left:10px;" class="quantity" type="text" th:value="${li.daycount}" readonly="readonly" value="1" id="quantity" size="5" ></input><span style="font-size:20px" class="numAdd" onclick="numAdd()"> + </span>人<br></br></div>
<div id="point" style="margin-top:10px;"><span>* 送 积 分 </span><input type="text" id="pointcount" style="width:150px;margin-left:30px;border-radius:5px" th:value="${li.pointcount}"></input><br></br></div>
<div id="isEcoupon" class="isEcoupon" style="margin-top:10px;"><span>*赠 送 优 惠 券 </span><select style="width:150px;border-radius:5px;height:25px" class="isEcoupon"><option value="1" th:selected="${li.isecoupon==1}" selected="selected">赠送</option><option th:selected="${li.isecoupon==0}" value="0">不赠送</option></select></div>
<div class="Ecoupon" id="Ecoupon" style="margin-top:10px;"><span>* 优 惠 券 </span>
<select name="selectcoupon" id="selectcoupon" style="margin-left:30px;height:25px;width:150px"><br></br>
<option th:if="${not #lists.isEmpty(lblist)}"
th:each="lb:${lblist}"
th:value="${lb.id}" th:text="${lb.cname}" th:selected="${li.cid!=null and li.cid==lb.id}">
</option>
<!-- <option th:value="${li.id}" th:text="${li.cname}" th:selected="${li.cid!=null and li.cid==lb.id}"></option> -->
</select></div>
<div><input type="hidden" id="id" th:value="${li.sid}"></input></div>
</div>
<br></br>
<div style="float:left;margin-left:10px;margin-bottom:30px">
<a class="sub" id="sub" >删除该条件</a>
</div>
<div style="float:right;margin-right:10px;margin-bottom:30px">
<a class="add" id="add">新增一个条件</a>
</div>
<div style="clear:both"></div>
</div>
这里说明一下 因为我们技术大佬喜欢使用些新奇的技术,例如这里不是使用的jsp,而是html静态页面,但这些数据的传输则使用的th标签,目前api也只有英文版的,想了解的朋友可以去谷歌一下usingthymeleaf.pdf 这是该api的英文文档
该param就是服务层传过来的map 调用这个addAllAttributes就可以将map传到页面中 因为本小白比较懒,页面的代码风格可能比较臃肿,很多的css都是自己写到标签中去了 打算后期在归类 总之当时是想先将功能实现出来 下面将展示前端页面的代码部分:
<div id="fathers">
<div id="context" class="context" th:if="${not #lists.isEmpty(ndlist)}" th:each="li:${ndlist}">
<div style="background:#fff;width:100%;margin-top:20px;text-align:left;height:170px;padding:10px;border-radius: 5px;">
<div id="person" style="margin-top:10px;"><span>* 推 荐 满</span><span style="font-size:30px;" class="numSub" id="numSub"> - </span><input style="width:150px;text-align:center;border-radius:5px;margin-left:10px;" class="quantity" type="text" th:value="${li.daycount}" readonly="readonly" value="1" id="quantity" size="5" ></input><span style="font-size:20px" class="numAdd" onclick="numAdd()"> + </span>人<br></br></div>
<div id="point" style="margin-top:10px;"><span>* 送 积 分 </span><input type="text" id="pointcount" style="width:150px;margin-left:30px;border-radius:5px" th:value="${li.pointcount}"></input><br></br></div>
<div id="isEcoupon" class="isEcoupon" style="margin-top:10px;"><span>*赠 送 优 惠 券 </span><select style="width:150px;border-radius:5px;height:25px" class="isEcoupon"><option value="1" th:selected="${li.isecoupon==1}" selected="selected">赠送</option><option th:selected="${li.isecoupon==0}" value="0">不赠送</option></select></div>
<div class="Ecoupon" id="Ecoupon" style="margin-top:10px;"><span>* 优 惠 券 </span>
<select name="selectcoupon" id="selectcoupon" style="margin-left:30px;height:25px;width:150px"><br></br>
<option th:if="${not #lists.isEmpty(lblist)}"
th:each="lb:${lblist}"
th:value="${lb.id}" th:text="${lb.cname}" th:selected="${li.cid!=null and li.cid==lb.id}">
</option>
<!-- <option th:value="${li.id}" th:text="${li.cname}" th:selected="${li.cid!=null and li.cid==lb.id}"></option> -->
</select></div>
<div><input type="hidden" id="id" th:value="${li.sid}"></input></div>
</div>
<br></br>
<div style="float:left;margin-left:10px;margin-bottom:30px">
<a class="sub" id="sub" >删除该条件</a>
</div>
<div style="float:right;margin-right:10px;margin-bottom:30px">
<a class="add" id="add">新增一个条件</a>
</div>
<div style="clear:both"></div>
</div>
这里说明一下 因为我们技术大佬喜欢使用些新奇的技术,例如这里不是使用的jsp,而是html静态页面,但这些数据的传输则使用的th标签,目前api也只有英文版的,想了解的朋友可以去谷歌一下usingthymeleaf.pdf 这是该api的英文文档
1 0
- springmvc传入map至前端
- springmvc 接收前端数据 map。数组
- springmvc 传入controller乱码
- springmvc 传入参数
- SpringMVC传入参数
- SpringMVC传入参数
- 传入Map返回实体
- 前端数据传入数据库实现
- springMvc 可传入的参数
- SpringMVC使用Map或MultiValueMap接收前端提交的Form Data或Query String
- springmvc与ajax传递单个对象代码、map形式数据,前端显示数据代码
- 后台数据传入前端乱码问题
- 前端 Highcharts图表,如何动态传入数据
- struts后端获取前端传入的值
- SpringMVC 传入参数(@PathVariable)乱码
- SpringMVC+easyUI多选传入后台
- 创建Excel报表(传入Map对象)
- mybatis使用map传入多个参数
- 排序
- Ext JS 6学习文档–第2章–核心概念
- setTimeout——内存泄漏
- 爬取糗事百科,朗读段子
- numpy-note
- springmvc传入map至前端
- 蓝桥杯基础练习: 查找整数
- 委托
- java学习笔记--解析xml
- 在Windows平台用visual studio编译的可执行文件部署时报:应用程序无法正常启动0xc000007b(跟DirectX9无关的原因)
- 构造方法和普通方法有什么区别呢,我很疑惑?
- poj 1942 Paths on a Grid (求组合数)
- C#调用PB写的com组件dll
- mac配置apache创建虚拟主机