解决@PathVariable参数接收不完整的问题
目录
- 解决@PathVariable参数接收不完整的问题
- 今天遇到的问题是:
- 解决办法:
- @PathVariable接受的参数可能为null
解决@PathVariable参数接收不完整的问题
今天遇到的问题是:
发送url参数接收不完整导致程序报错
http://localhost:8080/ddoe-control-center/orm/base/detail/com.sitech.ddoe.client.api.objopt.sample.Student动态参数是com.sitech.ddoe.client.api.objopt.sample.Student
由于有分隔符.导致接收到的参数少了一部分,
解决办法:
@RequestMapping("/base/detail/{dataObjectId:.+}")public ModelAndView detailDataObject(@PathVariable String dataObjectId) {.....}
参考文档:
@PathVariable出现点号”.”时导致路径参数截断获取不全的解决
@PathVariable接受的参数可能为null
@RequestMapping(value = https://www.it610.com/article/{"/getTreeNode/{id}","/getTreeNode"}, produces = "application/json; charset=UTF-8", method = RequestMethod.POST)@ApiOperation("查询树节点接口")public ListgetTreeNode(@PathVariable(value = "https://www.it610.com/article/id",required=false ) String id) throws Exception {return modelTreeServiceImpl.getTreeNode(id); }
1.加上required=false,
【解决@PathVariable参数接收不完整的问题】2.在mapping上加上"/getTreeNode",这样可以使required=false生效,当没有传参时会请求/getTreeNode
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
推荐阅读
- parallels|parallels desktop 解决网络初始化失败问题
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- MybatisPlus|MybatisPlus LambdaQueryWrapper使用int默认值的坑及解决
- SpringBoot调用公共模块的自定义注解失效的解决
- 解决SpringBoot引用别的模块无法注入的问题
- Spark|Spark 数据倾斜及其解决方案
- 解决SyntaxError:|解决SyntaxError: invalid syntax
- Spectrum|Spectrum 区块偶尔停止同步问题排查与解决笔记
- 一劳永逸地解决词汇量不够的问题
- [源码解析]|[源码解析] NVIDIA HugeCTR,GPU版本参数服务器---(3)