我当前正在调用 javax.servlet.http.Cookie
并在 Eclipse 中运行程序时收到 NoSuchMethodException
。 javax.servlet-api-4.0.0.x.jar
位于构建路径中。
这是我当前正在运行的代码:
method = cms.getClass().getMethod(field, javax.servlet.http.Cookie.class);
我也尝试过:
method = cms.getClass().getMethod(field, Cookie.class);
还有一个导入import javax.servlet.http.Cookie;
。对象cms
是一个用于连接到SQL服务器的Class
,field
是一个包含名称的String
被调用的方法。
最佳答案
您可能想使用getDeclaredMethod(field, Cookie.class)
。
getMethod(...)
仅返回 public 成员。
关于java - 使用反射的 javax.servlet.http.Cookie 的 NoSuchMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43947610/