• .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]


    当想要返回的是json数据,produces写的"text/plain",会报错

    @RequestMapping(value = "/getDynamicByDynamicId1",produces = "text/plain")
    @ResponseBody
    public Dynamic getDynamicByDynamicId1(){
    System.out.println();
    return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
    }

    Whitelabel Error Page

    This application has no explicit mapping for /error, so you are seeing this as a fallback.

    Thu Nov 21 15:01:12 CST 2019
    There was an unexpected error (type=Not Acceptable, status=406).
    Could not find acceptable representation
    org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
     
    改为
    @RequestMapping(value = "/getDynamicByDynamicId1",produces = "application/json")
    @ResponseBody
    public Dynamic getDynamicByDynamicId1(){
    System.out.println();
    return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
    }
  • 相关阅读:
    springMVC静态资源
    MyBatis Generator
    使用springMVC时的web.xml配置文件
    Semaphore
    spring注解驱动--组件注册
    第1章 初始Docker容器
    docker面试整理
    第5章 运输层
    验证码
    带进度条的上传
  • 原文地址:https://www.cnblogs.com/sunupo/p/11905763.html
Copyright © 2020-2023  润新知