wordpress 不能上传seo怎么优化一个网站

news/2025/9/28 23:11:23/文章来源:
wordpress 不能上传,seo怎么优化一个网站,网站建设培训简报,南通市优普网站建设摘要#xff1a;开发中经常需要校验用户提交的值是否满足要求#xff0c;Valid可用于方法参数、返回值等的验证#xff0c;但是对于参数为列表时无效#xff0c;此处记录几种对列表进行验证的方法 Valid 注解通常用于验证单个对象的字段#xff0c;而不是整个列表。仅添加…摘要开发中经常需要校验用户提交的值是否满足要求Valid可用于方法参数、返回值等的验证但是对于参数为列表时无效此处记录几种对列表进行验证的方法 Valid 注解通常用于验证单个对象的字段而不是整个列表。仅添加Valid注解不适用List原因Valid注解适用于Java Bean上的验证原生的List位于Java Util 并不属于Java Bean 所以验证器Valid不生效。 当需要对列表中的每个对象进行验证时通常可使用如下途径实现 1. 手动校验 通过手动验证可以自己定制复杂的校验逻辑但处理的数据多的时候工作量非常大。下例中遍历列表对其中的元素逐个手动校验价格和库存。 ApiOperation(后台批量更新商品) PostMapping(/admin/product/batchUpdate) public ApiRestResponse batchUpdateProduct(Valid RequestBody ListUpdateProductReq updateProductReqList) {for (int i 0; i updateProductReqList.size() ; i) {UpdateProductReq updateProductReq updateProductReqList.get(i);// 方法一 手动校验if (updateProductReq.getPrice() 1) {throw new ImoocMallException(ImoocMallExceptionEnum.PRICE_TO_LOW);}if (updateProductReq.getStock() 10000) {throw new ImoocMallException(ImoocMallExceptionEnum.STOCK_TO_MANY);}Product product new Product();BeanUtils.copyProperties(updateProductReq, product);productService.update(product);}return ApiRestResponse.success(); }2. 自定义列表 自定义列表自身具有将列表中属性验证的能力例如下例中的ValidList其仅仅是对List的接口简单封装了层。 ValidList类实现了 List 接口并在内部包含了一个使用了Valid注解的 List 对象。这个类的作用是具有校验能力的列表可以对其中的元素进行验证在使用ValidList类的时候如果给定的元素类上有相应的校验规则则可以通过Valid注解来触发校验。 除了包含校验能力的列表属性外ValidList 类还实现了List接口中的所有方法这些方法会直接调用内部的 list 对象的对应方法来完成相应的操作。这意味着可以像使用普通列表一样使用ValidList同时也能够享受到对元素的校验功能。 总之ValidList 类的设计在需要对列表元素进行校验的情况下方便地使用Bean Validation API提供的功能同时也保留了普通列表的所有操作特性。 ApiOperation(后台批量更新商品,validList验证) PostMapping(/admin/product/batchUpdate2) public ApiRestResponse batchUpdateProduct2(Valid RequestBody ValidListUpdateProductReq updateProductReqList) {for (int i 0; i updateProductReqList.size() ; i) {UpdateProductReq updateProductReq updateProductReqList.get(i);// 方法二 自定义列表Product product new Product();BeanUtils.copyProperties(updateProductReq, product);productService.update(product);}return ApiRestResponse.success(); }***ValidList.java*** package com.imooc.mall.common;import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import javax.validation.Valid; import java.util.List;/*** 具有检验能力的List*/ public class ValidListE implements ListE {Validprivate ListE list;public ValidList() {this.list new ArrayListE();}public ValidList(ListE list) {this.list list;}public ListE getList() {return list;}public void setList(ListE list) {this.list list;}Overridepublic int size() {return list.size();}Overridepublic boolean isEmpty() {return list.isEmpty();}Overridepublic boolean contains(Object o) {return list.contains(o);}Overridepublic IteratorE iterator() {return list.iterator();}Overridepublic Object[] toArray() {return list.toArray();}Overridepublic T T[] toArray(T[] a) {return list.toArray(a);}Overridepublic boolean add(E e) {return list.add(e);}Overridepublic boolean remove(Object o) {return list.remove(o);}Overridepublic boolean containsAll(Collection? c) {return list.containsAll(c);}Overridepublic boolean addAll(Collection? extends E c) {return list.addAll(c);}Overridepublic boolean addAll(int index, Collection? extends E c) {return list.addAll(index, c);}Overridepublic boolean removeAll(Collection? c) {return list.removeAll(c);}Overridepublic boolean retainAll(Collection? c) {return list.retainAll(c);}Overridepublic void clear() {list.clear();}Overridepublic E get(int index) {return list.get(index);}Overridepublic E set(int index, E element) {return list.set(index, element);}Overridepublic void add(int index, E element) {list.add(index, element);}Overridepublic E remove(int index) {return list.remove(index);}Overridepublic int indexOf(Object o) {return list.indexOf(o);}Overridepublic int lastIndexOf(Object o) {return list.lastIndexOf(o);}Overridepublic ListIteratorE listIterator() {return list.listIterator();}Overridepublic ListIteratorE listIterator(int index) {return list.listIterator(index);}Overridepublic ListE subList(int fromIndex, int toIndex) {return list.subList(fromIndex, toIndex);} }3. 使用Validated 注解 Validated是Spring提供的相对于Valid注解的功能的增强版支持集合内元素验证支持分组验证。 // Controller中添加注解 ValidatedApiOperation(后台批量更新商品,Validated验证) PostMapping(/admin/product/batchUpdate3) public ApiRestResponse batchUpdateProduct3(Valid RequestBody ListUpdateProductReq updateProductReqList) {for (int i 0; i updateProductReqList.size() ; i) {UpdateProductReq updateProductReq updateProductReqList.get(i);// 方法三 validatedProduct product new Product();BeanUtils.copyProperties(updateProductReq, product);productService.update(product);}return ApiRestResponse.success(); }使用 Validated所对应抛出的异常需要特殊处理下在全局异常处理类中添加; ExceptionHandler ResponseBody ResponseStatus(HttpStatus.OK) public ApiRestResponse handle(ConstraintViolationException exception) {// 从exception中获取到所有的验证违规信息并存储在一个Set集合中SetConstraintViolation? violations exception.getConstraintViolations();// 创建一个StringBuilder对象用于构建错误信息的字符串StringBuilder builder new StringBuilder();for (ConstraintViolation? violation: violations) { // 遍历违规信息的集合builder.append(violation.getMessage()); // 将当前违规信息的错误消息追加到builder中break; // 在处理完第一条违规信息后跳出循环} // 传入错误码和错误消息构建一个响应对象并将其作为方法的返回值return ApiRestResponse.error(ImoocMallExceptionEnum.REQUEST_PARAM_ERROR.getCode(), builder.toString()); }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/921245.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

网站建设模拟实验报告湛江网站制作费用

题目2: EXTERNAL关键字的作用?[多选] A、EXTERNAL关键字可以让用户创建一个外部表 B、创建外部表时,可以不加EXTERNAL关键字 C、通过EXTERNAL创建的外部表只删除元数据,不删除数据 D、不加EXTERNAL的时候,默认创建内…

wordpress导航菜单居中百度关键词优化首选667seo

算法: 这道题可以用回溯,但是可能会超时 可以用背包问题解决: 物品:单词 背包:字符串: 单词能否组成字符串s,就是问物品能不能把背包装满。 拆分时可以重复使用字典中的单词,就…

天津广告公司网站建设建网站手续

python的redis库查询返回的值默认是返回字节串,可以在redis.Redis()方法中通过设置decode_responses参数,让返回值直接是字符串; 查询返回字节串是因为Redis()方法中decode_responses默认值是False: 设置decode_responses为True就…

建立网站项目网络游戏排行榜2022

实现一个一遍扫描的编译前端&#xff0c;将简化高级语言的部分语法成分&#xff08;含赋值语句、分支语句、循环语句等&#xff09;翻译成四元式&#xff08;或三地址代码&#xff09;&#xff0c;还要求有合理的语法出错报错和错误恢复功能。 测试样例 beginwhile a<b do…

WordPress文章设置固定链接或永久链接 - 教程

WordPress文章设置固定链接或永久链接 - 教程pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", &qu…

垫江网站建设哪家好产品招商网

一、安装完虚拟机后的操作 第一步: 第二步&#xff1a;分配的内存大一下&#xff0c;处理器多些 第三步&#xff1a;打开虚拟化 打开虚拟机、安装KVM 一般企业如果使用kvm虚拟化平台&#xff0c;都会把物理服务器装成Centos的操作系统&#xff0c;然后装上kvm&#xff0c;创建…

尚义住房和城乡规划建设局网站广告设计专业前景

文章目录 嫌啰嗦直接看源码Q5 :PyTorch on CIFAR-10three_layer_convnet题面解析代码输出 Training a ConvNet题面解析代码输出 ThreeLayerConvNet题面解析代码输出 Train a Three-Layer ConvNet题面解析代码输出 Sequential API: Three-Layer ConvNet题面解析代码输出 CIFAR-1…

个人用云计算学习笔记 --15. (Linux 系统启动原理、Linux 防火墙管理)) - 实践

个人用云计算学习笔记 --15. (Linux 系统启动原理、Linux 防火墙管理)) - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-f…

给小孩出数学题

给小孩出数学题import java.util.Random; import java.util.Scanner; public class math_problems { public static void main(String[] args){ Random r=new Random(); Scanner sc=new Scanner(System.in); int probl…

dotnet项目编译运行

dotnet build - 基本构建 dotnet build PurestAdmin.Zero/PurestAdmin.Zero.csproj# 指定解决方案文件 dotnet build PurestAdmin.sln构建的常用参数 # 指定配置(Debug 或 Release) dotnet build --configuration Re…

linux virtualenv使用

在Linux系统中,virtualenv是一个用于创建虚拟环境的Python包。它允许你在不同的Python版本或不同的Python环境中安装和管理库。以下是如何在Linux中使用virtualenv的步骤:首先,确保你已经安装了Python。如果没有,请…

已有网站做google推广成都网站seo设计

0 软件开发人员自我成长 1 每天读2~3篇文章&#xff0c;可以行业趋势、技术类(和自己的工作有关的) 大厂技术博客科技资讯类&#xff1a;量子位、差评、新智元、无敌信息差 量子位、新智元经验分享、编程趋势、技术干活&#xff1a;程序员鱼皮、小林coding、java guide、程序…

实用指南:kafka详解

实用指南:kafka详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "…

06-基于FPGA和LTC2308的数字电压表设计-ModelSim仿真与Matlab模拟信号产生 - 详解

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

详细介绍:whisper-large-v3部署详细步骤,包括cpu和gpu方式,跟着做一次成功

详细介绍:whisper-large-v3部署详细步骤,包括cpu和gpu方式,跟着做一次成功2025-09-28 22:42 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-…

oracle_19c_ru_ojvm_upgrade.sh一键升级脚本分享

oracle_19c_ru_ojvm_upgrade.sh一键升级脚本分享2025-09-28 22:43 潇湘隐者 阅读(0) 评论(0) 收藏 举报oracle_19c_ru_ojvm_upgrade.sh脚本的初始版本来源于IT邦德的分享,使用原脚本时发现有一些bug,在我的环境中…

域名不变 网站改版如何知道网站开发语言

2019独角兽企业重金招聘Python工程师标准>>> 前景 Python在编程领域的占有率一直处于稳步上升之中&#xff0c;根据最新的数据&#xff0c;Python排名第六。前五名分别是 Java、C、PHP、C 和 VB. 作为一个很年轻的语言&#xff0c;Python的位置已经相当令人振奋了。…

数据类型-列表

列表 (可变类型):info= ["guohan",1,"222","xxx"] 公共功能:1.索引:  info[0]>>>"guohan"2.切片:  info[1;3]>>>[1,"222"]3步长:  …

2025/9/28

2025/9/28今日:1.学习离散数学 2.继续学习算法