多表单同时修改 Freemarker + controller + service
来源:互联网 发布:php就业方向 编辑:程序博客网 时间:2024/05/21 13:22
controller:@RequestMapping("/allSave") public String allSave(@RequestParam(value = "effectData") String effectData, RedirectAttributesModelMap model, HttpSession httpSession) { try { OperatorDO opDo = (OperatorDO) httpSession.getAttribute(Constant.SESSION_USER_KEY);// 获取当前用户 String parentId = (String) httpSession.getAttribute(SESSION_LAW02_PARENTID); law01Service.allSave(effectData,opDo.getName()); model.addAttribute("id", parentId); model.addFlashAttribute(Constant.MESSAGE, " 操作成功。"); } catch (Exception e) { model.addFlashAttribute(Constant.ERRMSG, " 出现错误,操作失败"); } return "redirect:/law02/show";
service:public void allSave(String effectData,String loginUser) { if (StringUtils.isEmpty(effectData)) { return; } String[] rows = effectData.split(";"); if (rows == null) {<pre name="code" class="javascript">
<pre name="code" class="java"><pre name="code" class="javascript">js:function allSave(){ var tableData = ""; //存所有数据 $("#lawFileList tr:not(:first)").each(function(){ //遍历除标题行外所有行 var rowData="["; $("input",this).each(function(){ //遍历行内的input 的值id rowData+=$(this).val(); }); rowData+=","; $("select",this).each(function(){ //遍历行内的select的值效力范围 rowData+=$(this).val(); }); rowData+="]"; tableData+=rowData+";"; //全部数据, 行与行之间“;”隔开 }); tableData = tableData.substring(0, tableData.length-1); if (tableData.length<=0) { return; } $('#effectData').val(tableData); $("#effectModForm").attr("method", "POST"); $("#effectModForm").submit(); }
return; } for (int i=0; i<rows.length;i++) { String[] rowData = rows[i].replace("[", "").replace("]", "").split(","); String id = rowData[0]; String effectId = rowData[1]; LawDO law = lawDAO.getLawById(id); if (law!=null) { if (law.getEffectId()!=Integer.valueOf(effectId)) { law.setEffectId(Integer.valueOf(effectId)); law.setUpdUser(loginUser); lawDAO.updateLawEffect(law); } } } }
freemaker:<table class="table table-bordered table-striped" id="lawFileList"><tbody> <tr> <th style="display:none;">ID</th> <th width="20%">文件名称</th> <th width="20%">内容</th> <th width="20%">效力范围</th> <th width="20%">操作</th> </tr><#list listFile! as x><tr><td style="display:none;"><input type ="text"value ="${x.id!}" /></td><td>${x.title!}</td><td><a href="http://121.40.84.119:8080/lvshitongfile/upload${(x.content)!}" target="_blank">点击查看内容</a></td><td> <select class="input input-auto" value="${(x.effectId)!}" > <option value ="1102" <#if ((x.effectId!'')?string == '1102')> selected="selected" </#if> selected="selected" >法律</option> <option value ="1103" <#if ((x.effectId!'')?string == '1103')> selected="selected" </#if> >司法解释</option> <option value ="1104" <#if ((x.effectId!'')?string == '1104')> selected="selected" </#if> >行政法规</option> <option value ="1105" <#if ((x.effectId!'')?string == '1105')> selected="selected" </#if> >规章及其他</option></td><td><a onclick="confirmDeleteFile('${(x.title)!}','${(x.content)!}')">删除</a></td></tr ></#list> </tbody> </table> <br/> <form id="effectModForm" method ="post" action ="${base}/law02/allSave"> <input type="hidden" name="effectData" id="effectData"> </form> <button class="button bg-main" onclick ="allSave()">全部保存</button>
0 0
- 多表单同时修改 Freemarker + controller + service
- @Controller ~ @Service
- spring aop同时代理service层和controller层的问题
- 一个表单同时提交多条记录
- springMVC+freemarker请求Controller错误
- springMVC+freeMarker表单验证
- @Component @Service @Controller @Repository
- :@Repository、@Service 和 @Controller。
- Controller Service Dao总结
- service 和 Controller 区别
- dao、service、controller、view
- @Component、@Repository @Service、@Controller
- Action(controller) service DAO
- @Component @Service @Controller @Repository
- @Component,@Service,@Controller,@Repository
- @Repository @Service @Controller @Component
- Controller->Service->Repository
- controller-service-dao-entity
- javascript数组的长度length是可变的
- [php学习二]基本语法练习一
- 属性读写操作小例子
- SQL语句中的or、in、and
- django开发基本步骤
- 多表单同时修改 Freemarker + controller + service
- 抽象类与接口的区别
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- 使用selenium webdriver从隐藏元素中获取文本
- Java相关 关键字
- MAC 通过命令行快速的显示隐藏文件
- 最短路径 [弗洛伊德算法] --->图
- 流与反射
- java服务安装(二):使用commons-daemon