0

I am calling a web api (J2ee, for example : /getBlDetail/{noBl}) with $resource:

return $resource('api/getBlDetail/:noBl', {}, {
            'query': { method: 'GET', isArray: true},
            'get': {
                method: 'GET', isArray: true,
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    return data;
                }
            }
        });

J2EE :

@RequestMapping(value = "/getBlDetail/{noBl}",
            method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Vente> getBlDetail(@PathVariable String noBl) {
    try {
        noBl = java.net.URLDecoder.decode(noBl, "UTF-8");
        ...
        return ventes;
    } catch (UnsupportedEncodingException e) {
        return null;
    }
}

If for example noBl = '04.00256', in java side I am only getting '04'. It seems that the "." character is not accepted. I have tried : encodeURIComponent(bl.noBl) But the problem is the same.

Is there a way to use a parameter in $resource that contains the "." character?

Thanks in advance.

user1260928
  • 3,269
  • 9
  • 59
  • 105

1 Answers1

2

You need to specify the URL differently, like so:

/somepath/{variable:.+}

Further explanation in this question: Spring MVC @PathVariable with dot (.) is getting truncated

Community
  • 1
  • 1
st2rseeker
  • 473
  • 1
  • 5
  • 28