怎样在Servlet里面得到js页面out打印的文本框值?
为什么用了int bookpnum=Integer.valueOf(request.getParameter("bookpnum"));还是得不到这个值。
方式只有一种。
步骤:
1、获取response对象
2、获取response的printwriter对象
3、通过printwriter的pring方法输出js
示例代码:
123456789 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter();//通过servlet的doget方法获取response对象,通过getWriter方法获取PrintWriter对象 out.flush();//清空缓存 out.println("<script>");//输出script标签 out.println("alert('此用户名已存在,请重新输入!');");//js语句:输出alert语句 out.println("history.back();");//js语句:输出网页回退语句 out.println("</script>");//输出script结尾标签 }
热门标签: