错误信息:Required request parameter 'XXX' for method parameter type String is not present

这种都是前端请求方式不同,后端处理方式不同

  • 可以设置一下dataType
  • 一定要注意 @ResponseBody 的使用

最终在一个博主评论下面看见了解决答案:

还有一个致命的一点,@ResponseBody本身不强制内容,返回的就是文本。如果方法体返回的是对象,大概率会调用这个对象的toString(),可以是重写也可以继承的,如果是JSON对象也是这样。具体这个我没测试,因为我用@ResponseBody的所有controller方法都强制是自己可控的String,如果你的controller方法参数是Integer,并且加了注解@ResponseBody,绝大多数报错。需要改成String 型的。

错误:Required request parameter 'XXX' for method parameter type String is not present的更多相关文章

  1. android switch(String)错误:Cannot switch on a value of type String for source level below 1.7

    switch语句的判断条件可以接受int,byte,char,short,不能接受其他类型只有JDK版本1.7以上才可以支持String 设置如下可解决问题:(若没有JDK1.7版,可下载一下安装)菜 ...

  2. @RequestBody对象为空,异常Required request body is missing错误解决

    1.异常 org.springframework.http.converter.HttpMessageNotReadableException: Required request body is mi ...

  3. DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing

    客户端当发送空的json字符串时,请求RestController时,报错: DefaultHandlerExceptionResolver : Failed to read HTTP message ...

  4. required string parameter XXX is not present

    @RequestParam jQuery调用方式: deleteFile: function(filePath) { return ajax({ method: 'POST', url: '/cm/s ...

  5. required string parameter 'XXX'is not present 的几种情况

    required string parameter 'XXX'is not present 的几种情况 情况一:原因是由于头文件类型不对,可以在MediaType中选择合适的类型,例如GET和POST ...

  6. Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration required a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactor

    Error starting ApplicationContext. To display the conditions report re-run your application with 'de ...

  7. Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a single bean, but 2 were found:

    Parameter 0 of method orderSqlSessionFactory in com.config.MultipleDBConfig required a single bean, ...

  8. 报错:required string parameter XXX is not present

    报错:required string parameter XXX is not present 不同工具发起的get/delete请求,大多数不支持@RequestParam,只支持@PathVari ...

  9. Better exception message for missing @RequestBody method parameter

    https://jira.spring.io/browse/SPR-12888 Description When I use @RequestBody on one of my controllers ...

  10. 请求(Request)的参数(Parameter)里包含特殊字符(#等)的正确处理方式

    遇到一个问题 在一个地址链接(URL)里使用 url?param1=val1&param2=val2 的方式传递参数,结果在获取参数值时发现不是当初设定的值. 具体案例 以特殊字符井号(#)为 ...

随机推荐

  1. 在k8s中将nginx.conf文件内容创建为ConfigMap挂载到pod容器中

    将nginx.conf文件内容创建为ConfigMap user nginx; worker_processes auto; error_log /var/log/nginx/error.log er ...

  2. Elasticsearch 开发入门 - Python

    文章转载自:https://elasticstack.blog.csdn.net/article/details/111573923 前提条件 你需要在你的电脑上安装 python3 你需要安装 do ...

  3. 使用cnpm创建vue项目(含离线安装)

    # 全局安装淘宝cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org #升级 npm cnpm install npm ...

  4. vue中a标签地址传参

     注意:  1)href前面加冒号"  :  ".     2)字符串用单引号包裹 .     3)传过去数值用+号连接 传值:<li class="list-li ...

  5. Java程序设计(三)作业

    题目1:用户输入学号,如果是以ccutsoft开头,并且后边是4位数字,前两位大于06小于等于当前年份.判断用户输入是否合法.ccutsoft_0801. 1 //题目1:用户输入学号,如果是以abc ...

  6. P7962 [NOIP2021] 方差 (DP)

    题目的意思就是可以交换差分数组,对答案进行化简:n∑ai2​−(∑ai​)2 ,再通过手玩分析可得最优解的差分数组一定是单谷(可以感性理解一下),因此我们将差分数组排序,依次加入,每次可以选择加在左边 ...

  7. 洛谷P3690 (动态树模板)

    一位大佬写的代码.(加上我自己的一些习惯性写法) 存个模板. 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N= ...

  8. IDEA中直接将 SpringBoot项目打包成 Docker镜像时 pom.xml的配置

    <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactI ...

  9. Unexpected token u in JSON at position 0

    文章目录 1.1 错误原因: 1.2 解决思路: 1.1 错误原因: 因为JSON.parse()不能解析字符串中的undefined 出错的结果:某一行的这个字段的值为空,就会报错,整个表格都显示不 ...

  10. 豆瓣电影排行简单数据爬取_pyhton

    先安装一下requests和bs4库: cmd下面:python -m pip install bs4 -i https://pypi.douban.com/simple 代码: import req ...