页面批量新增
来源:互联网 发布:被猎头找到 知乎 编辑:程序博客网 时间:2024/06/05 08:00
jsp:
<tr>
<th class="center span1">
<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
</th>
<th class="center span1">序号 </th>
<th class="center span2 sort">姓名 <span class="sj"></span></th>
<th class="center span2 sort">状态 <span class="sj"></span></th>
<th class="center span2 sort">次数 <span class="sj"></span></th>
</tr>
<c:forEach items="${studentList}" var="v" varStatus="vs">
<tr>
<td class='center' style="width: 30px;">
<label><input type='checkbox' name='ids' /><span class="lbl"></span></label>
</td>
<td class='center' style="width: 30px;">${vs.index+1}</td>
<td>${v.name}</td>
<input type="hidden" name='name${ v.studentId}' id='name' value="${v.id }">
<input type="hidden" name='studentId${ v.studentId}' id='studentId' value="${v.studentId }">
<td ><select name="status${ v.studentId}" id="status" data-placeholder="请选择状态" style="vertical-align:top;width: 100px;">
<option value="1" <c:if test="${pd.status == '1'}">selected="selected"</c:if>>正常出勤</option>
<option value="2" <c:if test="${pd.status == '2'}">selected="selected"</c:if>>早退</option>
<option value='3' <c:if test="${pd.status == '3'}">selected="selected"</c:if>>迟到</option>
<option value='4' <c:if test="${pd.status == '4'}">selected="selected"</c:if>>未到</option>
<option value='5' <c:if test="${pd.status == '5'}">selected="selected"</c:if>>请假</option>
</select>
</td>
<td><select name="number${ v.studentId}" id="number" data-placeholder="请选择考勤次数" style="vertical-align:top;width: 100px;">
<option value="1" <c:if test="${pd.number == '1'}">selected="selected"</c:if>>1次</option>
<option value="2" <c:if test="${pd.number == '2'}">selected="selected"</c:if>>2次</option>
<option value='3' <c:if test="${pd.number == '3'}">selected="selected"</c:if>>3次</option>
</select>
</td>
</tr>
</c:forEach>
因为studentId是唯一的,这样避免数据的覆盖
java :
/*
* / 批量新增
*/
@RequestMapping(value = "saveLast")
public ModelAndView saveLast(HttpServletRequest request) {
String classid=request.getParameter("classId");
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();//封装好的
pd = this.getPageData();//获得前台的值
try {
List<String> list = new ArrayList<>();
Iterator<String> iter = pd.keySet().iterator();
while (iter.hasNext()) {
//获得键key
String key = iter.next();
list.add(key);
}
Map<String, String> map = new HashMap<>();
for (String aa : list) {
//获得其中一类key和value name=“123123123” name=“123123122”
if (aa.substring(0, 4).equals("name")) {
map.put(aa.substring(4), "name");
}
}
for(Map.Entry<String, String> m: map.entrySet()){
String key = m.getKey();
PageData pData = new PageData();
//根据key获得value,一条一条插入
pData.put("id",this.get32UUID());
pData.put("name",pd.get("name"+key));
pData.put("studentId",pd.get("studentId"+key));
pData.put("datatime",datatime);
pData.put("number",pd.get("number"+key));
pData.put("status",pd.get("status"+key));
attendanceService.save(pData);
}
} catch (Exception e) {
// TODO: handle exception
logger.error(e);
}
mv.addObject("msg", "success");
mv.setViewName("save_result");
return mv;
}
前台值是通过表单提交传到后台的
- 页面批量新增
- 页面新增
- form表单 批量新增
- 通用新增(批量 实体)
- mybatis 批量新增
- mybatis的批量新增
- MyBatis批量新增、更新
- mybatis的批量新增
- MyBatis的批量新增
- mybatis的批量新增
- sqlserver批量新增数据
- mybatis的批量新增
- Mybatis批量新增,修改
- EF批量新增优化
- Mybatis批量新增
- 批量新增数据
- mybaits批量新增修改
- spring jdbctemplate 批量新增
- C++(清华篇)STL的基本概念
- 使用深度学习和树搜索进行从零开始的既快又慢的学习
- 安装nodejs提示2502处理方法
- 安装CocoaPods最简单教程三步走
- 使用js得到当前页面的url信息方法
- 页面批量新增
- cxDateEdit的格式问题
- 遍历二叉树
- 人工智能领域的几个的技术大牛博客
- 安装Docker Compose
- 2017hdu新生赛 1006 稿件整理
- Struts2基本的执行过程
- MissingResourceException: Can't find resource for bundle java....错误解决
- Android:SwipeRefreshView嵌套DockingExpandableListView 悬停标题外加上拉刷新下拉加载