在servlet中dopost或doget如何调用自己写的方法呢?
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException { }
下面比如是我自己写的一个方法
public void add()
{ }
DOGET()或DOPOS() 该如何调用add()呢?
------解决方案--------------------protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
add();
}
------解决方案--------------------doGet(...){
add(request,response);
}
private void add(HttpServletRequest request,HttpServletResponse response){
//...
}