我有这个 servlet -
@WebServlet("/CreateNewPersonServlet")
public class CreateNewPersonServlet extends HttpServlet {
private void saveInDB() {
// here use the invoke ...
String methodName = "saveManager";
Method method = CreateNewPersonServlet.class.getMethod(
methodName, new Class[] {});
method.invoke(this);
}
private void saveManager() {
}
}
当奔跑到达终点线时——
Method method = CreateNewPersonServlet.class.getMethod(
methodName, new Class[] {});
它抛出异常 -
java.lang.NoSuchMethodException: control.CreateNewPersonServlet.saveManager()
at java.lang.Class.getMethod(Unknown Source)
我应该如何正确编写调用?