Java Angularjs:如何通过&引用;字符转换为$resource的参数
我正在使用$resource调用一个web api(J2ee,例如:/getBlDetail/{noBl}):Java Angularjs:如何通过&引用;字符转换为$resource的参数,java,javascript,angularjs,rest,Java,Javascript,Angularjs,Rest,我正在使用$resource调用一个web api(J2ee,例如:/getBlDetail/{noBl}): return $resource('api/getBlDetail/:noBl', {}, { 'query': { method: 'GET', isArray: true}, 'get': { method: 'GET', isArray: true, transform
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;
}
}
@RequestMapping(value=“/getBlDetail/{noBl}”,
method=RequestMethod.GET,
products=MediaType.APPLICATION\u JSON\u值)
@定时
公共列表getBlDetail(@PathVariable String noBl){
试一试{
noBl=java.net.urldecover.decode(noBl,“UTF-8”);
...
回流通风口;
}捕获(不支持的编码异常e){
返回null;
}
}
例如,如果noBl='04.00256',在java端我只得到'04'。
似乎不接受“.”字符。
我尝试过:encodeURIComponent(bl.noBl)
但问题是一样的
是否有方法使用$resource中包含“.”字符的参数
提前感谢。您需要以不同的方式指定URL,如下所示: /somepath/{变量:.+} 关于这一问题的进一步解释: