有没有办法从一个领域获得实例?
这是一个示例代码:
public class Apple {
// ... a bunch of stuffs..
}
public class Person {
@MyAnnotation(value=123)
private Apple apple;
}
public class AppleList {
public add(Apple apple) {
//...
}
}
public class Main {
public static void main(String args[]) {
Person person = new Person();
Field field = person.getClass().getDeclaredField("apple");
// Do some random stuffs with the annotation ...
AppleList appleList = new AppleList();
// Now I want to add the "apple" instance into appleList, which I think …Run Code Online (Sandbox Code Playgroud) 我正在使用AngularJS v1.2.16和Restangular v1.4.0,并想知道是否可以覆盖ErrorInterceptor.如果有,怎么样?如果不是,我该如何解决?
我已经配置了一个错误拦截器,如下所示:
RestangularProvider.setErrorInterceptor(
function ( response ) {
if ( response.status == 401 ) {
dialogs.error("Unauthorized - Error 401", "You must be authenticated in order to access this content.")
.result.then( function () {
$location.path("/login");
});
}
else {
// Some other unknown Error.
console.log( response );
dialogs.error(response.statusText + " - Error " + response.status,
"An unknown error has occurred.<br>Details: " + response.data);
}
// Stop the promise chain.
return false;
}
);
Run Code Online (Sandbox Code Playgroud)
然后,在另一个地方,我进行了一个错误处理的POST调用.
function …Run Code Online (Sandbox Code Playgroud)