Parameter[] ps = method.getParameters();
Map<String,Integer> map = new HashMap<String,Integer>();
for(int ij = 0;ij<ps.length;ij++){
Parameter p = ps[ij];
RequestParam rp = p.getAnnotation(RequestParam.class);
if(rp != null){
//do something
}else {
System.out.println(p.getType());
System.out.println(p.getType().isInstance(HttpServletRequest.class));
System.out.println(p.getType() == HttpServletRequest.class);
}
}
the output is:
interface javax.servlet.http.HttpServletRequest
false
true
why use the "isInstance" is false and use "==" is true? because the "instance of" can't judge implements relationship?
The type isn't an instance of the HttpServletRequest
class, it's an instance of java.lang.Class
that contains the information about the HttpServletRequest
class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With