在你编写的Servlet类里面有一个doGet和doPost方法,举个例子:
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/html");
response.setCharacterEncoding("gb2312");
String username=request.getParameter("name");//其中name就是你页面传递过来的参数名称,它的值就存储在String变量username里面了。同样若是通过post方式传递数据的话,只需要在doPost方法里面调用这个doGet方法就行了。如下:
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
doGet(request,response);
}
你想问的是这个吗?
HttpServletRequest req
req.getParameter("xxx");
HttpServletRequset.getParameter("xxx");