大家好,又见面了,我是全栈君。
这是第一种使用的是onload方法当中的test是自己的servlet
<html> <body onload = "test"> </body> </html>
以下是用的js调用servlet实现
<script language='javascript'> function test(){ window.open('','','')//參数可设你要调用的servlet, //可让此页面在台执行 } </script>
如今在jsp中使用session验证用户是否登录
<% if(session.getAttribute("userinfo") == null) { %> <script type="text/javascript" language="javascript"> alert("您还没有登录,请登录..."); window.document.location.href="userlogin.html"; </script> <% } %>
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116318.html原文链接:https://javaforall.net