现在的位置: 首页 > 综合 > 正文

使一个Servlet上同时支持GET和POST

2013年08月31日 ⁄ 综合 ⁄ 共 346字 ⁄ 字号 评论关闭

使一个Servlet上同时支持GETPOST

  在Servlet的编写中常常遇到在同一个Servlet上需要同时支持GETPOST方法。可以通过如下方法来实现:把所有的操作都在doGet里实现,然后在doPost里调用doGet方法。实现代码段如下:

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{

//----操作

}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException

{

doGet(req, res);

}

 

抱歉!评论已关闭.