解决@PathVariable参数接收不完整的问题

解决@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
    由于有分隔符.导致接收到的参数少了一部分,
    【解决@PathVariable参数接收不完整的问题】
    解决办法:@RequestMapping("/base/detail/{dataObjectId:.+}")public ModelAndView detailDataObject(@PathVariable String dataObjectId) {.....}
    参考文档:
    @PathVariable出现点号”.”时导致路径参数截断获取不全的解决
    @PathVariable接受的参数可能为null@RequestMapping(value = https://www.yf-zs.com/redian/{"/getTreeNode/{id}","/getTreeNode"}, produces = "application/json;charset=UTF-8", method = RequestMethod.POST)@ApiOperation("查询树节点接口")public List<ModelTreeDto> getTreeNode(@PathVariable(value = "https://www.yf-zs.com/redian/id",required=false ) String id) throws Exception {return modelTreeServiceImpl.getTreeNode(id);}
    1.加上required=false,
    2.在mapping上加上"/getTreeNode",这样可以使required=false生效,当没有传参时会请求/getTreeNode
    以上为个人经验,希望能给大家一个参考,也希望大家多多支持趣讯吧 。