springMvc @PathVariable传递小数丢失的解决方法

@RequestMapping(value = "/V6/serviceDirectSearch/{bcId}/{name:.+}", method = RequestMethod.POST)
    @ResponseStatus(value = HttpStatus.OK)
    @ResponseBody
    public void getPlayStoreServiceSearch(@PathVariable(value = "bcId") String bcId,@PathVariable(value = "name") String name ) {

        ResponseEntity responseEntity = new ResponseEntity();

        try {
            List playStoreServiceList = playStoreService.getPlayStoreServiceSearch(bcId, name);
            responseEntity.setResult(playStoreServiceList);
            super.setResponse(responseEntity);
            return;
        } catch (BusinessException bex) {
            responseEntity.setting(bex.getCode(), bex.getMessage());
            System.err.println(super.getDate() + "--" + bex.getCode() + ": " + bex.getMessage());
            super.setResponse(responseEntity);
            return;
        } catch (Exception e) {
            responseEntity.setting(CodeEnum.SERVER_ERROR);
            e.printStackTrace();
            super.setResponse(responseEntity);
            return;
        }
    }

解决方案:
{name:.+}
上述代码中,如果name为小于1的小数,如0.15,则传递给name的值为0, 查资料, 必须对{name}点位符进行如下修饰:{name:.+}

你可能感兴趣的:(springMvc @PathVariable传递小数丢失的解决方法)