发布网友 发布时间:2022-04-22 18:11
共3个回答
热心网友 时间:2023-11-14 20:51
public class request_2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String value=request.getParameter("userName");
if(value!=null && !value.trim().equals(""))
System.out.println("userName: "+value);
response.getRequestDispatch(url).forward(request,response);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req,resp);
}
}
你servlet没有跳转,请跳转response.getRequestDispatch(url).forward(request,response);
加这句
url为你的jsp地址
热心网友 时间:2023-11-14 20:51
doGet(req,resp);
你在doPost里面要又调用doGet
但是你页面上是以post方式访问servlet,所以到了doGet(req,resp)这个地方,无法处理;追问public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String value=req.getParameter("userName");
if(value!=null && !value.trim().equals(""))
System.out.println("userName: "+value);
}
}
这样还是不行
热心网友 时间:2023-11-14 20:52
是我眼睛有问题吗,应该是request.getRequestDispatch(url).forward(request,response);吧