批量:获取编辑列表及提交
来源:互联网 发布:重庆爱知日语招聘 编辑:程序博客网 时间:2024/06/02 02:56
1
// 批量编辑列表@RequestMapping("/editItemsQuery")public ModelAndView editItemsQuery(HttpServletRequest request,ItemsQueryVo itemsQueryVo) throws Exception {List<ItemsCustom> itemsList = itemsService.findItemsList(itemsQueryVo);ModelAndView modelAndView = new ModelAndView();modelAndView.addObject("itemsList", itemsList);modelAndView.setViewName("items/editItemsQuery");return modelAndView;}// 批量编辑提交@RequestMapping("/editItemsAllSubmit")public String editItemsAllSubmit(ItemsQueryVo itemsQueryVo)throws Exception {return "success";}
2.springmvc注解开发-validation校验-商品修改校验
// 编辑提交@RequestMapping("/editItemsSubmit")public String editItemsSubmit(HttpServletRequest request,Integer id,@Validated ItemsCustom itemsCustom,BindingResult bindingResult) throws Exception {// 获取校验错误信息if (bindingResult.hasErrors()) {// 输出错误信息List<ObjectError> allErrors = bindingResult.getAllErrors();for (ObjectError objectError : allErrors) {System.out.println("\n校验器下面:");// 输出错误信息System.out.println(objectError.getDefaultMessage());}}// 调用service更新商品信息,页面需要将商品信息传到此方法itemsService.updateItems(id, itemsCustom);return "success";}
CustomValidationMessages.properties
#添加校验错误提交信息items.name.length.error=请输入1到30个字符的商品名称items.createtime.isNUll=请输入商品的生产日期
这自来是POJO类名的
@Size(min=1,max=30,message="{items.name.length.error}") private String name; @NotNull(message="{items.createtime.isNUll}") private Date createtime;
<!-- 显示错误信息 --><c:if test="${allErrors!=null }"><c:forEach items="${allErrors }" var="error">${ error.defaultMessage } <br/></c:forEach></c:if>
3.springmvc注解开发-validation校验-分组校验
public interface ValidGroup1 {//接口中不需要定义任何方法,仅是对不同的校验规则进行分组//此分组只校验商品名称长度}
public interface ValidGroup2 {//接口中不需要定义任何方法,仅是对不同的校验规则进行分组}
//校验名称在1到30字符中间 //message是提示校验出错显示的信息 //groups:此校验属于哪个分组,groups可以定义多个分组 @Size(min=1,max=30,message="{items.name.length.error}",groups={ValidGroup1.class}) private String name;
// 编辑提交// value={ValidGroup1.class}指定使用ValidGroup1分组的 校验@RequestMapping("/editItemsSubmit")public String editItemsSubmit(Model model,HttpServletRequest request,Integer id,@Validated(value={ValidGroup1.class}) ItemsCustom itemsCustom,BindingResult bindingResult) throws Exception {
4.springmvc注解开发-数据回显
// @ModelAttribute可以指定pojo回显到页面在request中的key@RequestMapping("/editItemsSubmit")public String editItemsSubmit(Model model,HttpServletRequest request,Integer id,@ModelAttribute("items") @Validated(value={ValidGroup1.class}) ItemsCustom itemsCustom,BindingResult bindingResult) throws Exception {
// 商品类型//子路径itemtypes表示最终将方法返回值放在request中的key@ModelAttribute("itemtypes")public Map<String, String> getItemTypes() {Map<String, String> itemTypes = new HashMap<String, String>();itemTypes.put("101", "数码");itemTypes.put("102", "母婴");return itemTypes;}
<td>商品名称:<input name="itemsCustom.name" />商品类型:<select name="itemtype"><c:forEach items="${itemtypes }" var="itemtype"><option value="${itemtype.key }">${itemtype.value }</option></c:forEach></select></td>
// 获取校验错误信息if (bindingResult.hasErrors()) {// 输出错误信息List<ObjectError> allErrors = bindingResult.getAllErrors();for (ObjectError objectError : allErrors) {System.out.println("\n校验器下面:");// 输出错误信息System.out.println(objectError.getDefaultMessage());}model.addAttribute("allErrors", allErrors);model.addAttribute("items", itemsCustom);return "items/editItems";}
5.
6.
0 0
- 批量:获取编辑列表及提交
- struts2+easyui datagrid可编辑操作及列表数据提交
- 可编辑表格批量提交
- Ext 可编辑表格批量提交
- easyui datagrid 批量编辑和提交
- ui easyui datagrid 批量编辑和提交
- easyui datagrid 批量编辑和提交
- JQuery EasyUI datagrid 批量编辑和提交
- easyui datagrid 批量编辑和提交
- easyui datagrid 批量编辑和提交
- SpringMVC获取表单批量提交数据
- EasyUI学习之easyui datagrid 批量编辑和提交
- EasyUI学习之easyui datagrid 批量编辑和提交
- ORACLE 【INSERT】逐行提交、批量提交及极限提速方法
- Oracle逐行提交、批量提交及极限提速方法
- Oracle逐行提交、批量提交及极限提速方法
- python批量下载网页图片及列表
- python获取及提交测试
- 【人脸检测:Haar】利用积分图像法快速计算Haar特征(二)
- JS 倒计时
- 第七周--项目3负数把正数赶出队列
- LeetCode(96) Unique Binary Search Trees
- Windows下面编译libiconv
- 批量:获取编辑列表及提交
- ios10 关于app info.plist权限设置
- UITabbar的背景颜色
- CSS强制文本在一行内显示若有多余字符则使用省略号表示
- linux测试语句
- ubuntu 使用 find&grep 查找文件
- 【项目4 - 数制转换】
- 图像目标检测 知识点
- html修改定时刷新web页面