javascript - 当客户端发送无效的 uuid 时,服务器应该响应什么错误?
问题描述
我正在使用 Spring Boot 开发微服务。该服务在进入应用程序时生成uuid并发送给客户端,客户端将uuid保存在cookie中。现在,当客户端向资源发出请求时,会有一个过滤器检查 uuid 是否有效。
@Override
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain)
throws IOException, ServletException {
String uuid = req.getParameter("guest_uuid");
if (isValidUUID(uuid)){
chain.doFilter(req, res);
}else {
// respond with customer error
}
}
服务器应该响应什么错误,以便客户端(javascript)可以识别此错误并从 cookie 中删除 uuid?
解决方案
推荐阅读
- opalrb - 为什么 `require 'native'` 在 opalrb 中抛出异常?
- c - 结构中 char 指针的内存分配
- javascript - 谷歌认证后访问 GraphQL
- string - “字符串”类型不是“列表”类型的子类型
' 在类型转换中? - java - 对于不仅包含日期属性的对象的整个列表,如何将 LocalDateTime yyyy-MM-dd HH:mm 格式化为 dd-MM-yyyy HH:mm 作为字符串?
- python - 如何将使用 open() 加载的数据编码为 UTF-8?
- python - 如何用张量 np.concatenate 列表?
- powershell - 根据文件名移动文件
- r - 如何在环境中运行任意表达式,将所有结果存储在环境中?
- c# - 具有堆栈的项目的 Azure devops 管道任务:selenium、c#、Nunit、边缘浏览器