博客
关于我
Content type 'text/plain;charset=UTF-8' not supported
阅读量:216 次
发布时间:2019-02-28

本文共 1072 字,大约阅读时间需要 3 分钟。

在进行Postman测试时遇到一个异常,日志显示在2016年11月2日10:35:50,142ms,错误信息来源于com.confucian.framework.web.exception.ExceptionControllerAdvice:143。以下是详细分析和解决方案。

首先,查看请求的Controller代码:

@RequestMapping(path = "/register", method = RequestMethod.POST)public Object register(@RequestBody StudentRegisterBean registerInfo, HttpServletRequest request, HttpServletResponse response) {

这个请求处理的是POST方法,发送到/register路径,使用@RequestBody注解,接收的是StudentRegisterBean实体类。请求体数据通过@RequestBody注解自动解析为Java对象。

在使用Postman进行测试时,可能会遇到以下常见问题:

  • 数据传输格式不对:确保请求体数据以正确的格式发送,Postman的Content-Type设置应与后端处理器兼容。

  • 请求头信息不完整:Postman默认会设置必要的请求头,但如果后端有额外要求,可能需要手动添加。

  • 版本兼容性问题:检查Postman的版本是否与后端服务兼容,尤其是在使用HTTP基本认证或其他认证机制时。

  • 通过查看日志和Postman的截图,可以确认具体的错误原因。根据日志提示,错误发生在ExceptionControllerAdvice的143行,这表明异常处理逻辑可能在这里触发。

    解决方法如下:

  • 检查Content-Type:在Postman中,确保请求头的Content-Type设置为application/json或其他适用于StudentRegisterBean的格式类型。

  • 验证请求体格式:使用Postman的Preview功能,查看请求体的实际发送数据,确保与后端期望的数据格式一致。

  • 更新Postman插件:确保Postman插件已更新到最新版本,以避免已知的兼容性问题。

  • 检查日志中的错误信息:结合错误日志内容,查看是否有其他异常提示,例如认证失败、解析错误等。

  • 通过以上步骤,可以系统地定位并解决Postman请求失败的问题。遇到类似问题时,建议同时查看日志、Postman的请求头和请求体数据,以便快速定位问题根源。

    转载地址:http://fmms.baihongyu.com/

    你可能感兴趣的文章
    notepad如何自动对齐_notepad++怎么自动排版
    查看>>
    Notes on Paul Irish's "Things I learned from the jQuery source" casts
    查看>>
    Notification 使用详解(很全
    查看>>
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    NotImplementedError: Could not run torchvision::nms
    查看>>
    nova基于ubs机制扩展scheduler-filter
    查看>>
    Now trying to drop the old temporary tablespace, the session hangs.
    查看>>
    nowcoder—Beauty of Trees
    查看>>
    np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
    查看>>
    np.power的使用
    查看>>
    NPM 2FA双重认证的设置方法
    查看>>
    npm build报错Cannot find module ‘html-webpack-plugin‘解决方法
    查看>>
    npm build报错Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin‘解决方法
    查看>>
    npm build报错Cannot find module ‘webpack‘解决方法
    查看>>