怎么在servlet里使用alert弹出窗口?


  1. 调用gerWriter() 把script输出到页面

  2. response.getWriter().out("<script>alert("hello world!");</script>") ; 

  3. 页面就会弹出 hello world!   要学会分清楚应用程序的系统边界:在态蠢裂 JSP 中有一些代码是在服务器上执行的,而另一些代码则是在客户端执行的。

  4. 当然你也可以通过 跳转页帆闭面来实现,response.getSendRedirect(跳到那个档汪jsp页面的名称) ; 


使用Myclipse在创建的servlet里写段程序,要州洞碰册谈用到alert()的方式,在浏览器上显示时可以因为限制颤仿个东西而弹出窗口

response.setContentType("text/html;charset=UTF-8");//中文需设置编码

response.getWriter().write("<script>alert('腔滑租你伍兆好!');</script>"让桥);