读书人

如何解决弹出登陆对话框并且登陆成功

发布时间: 2012-03-17 19:06:28 作者: rapoo

怎么解决弹出登陆对话框,并且登陆成功后刷新主页面的问题《求核心代码》
我找过很多地方,但总感觉说的不是要的内容

就是弹出登陆对话框,登陆后连同登陆后的用户信息一起在JSP主页面中进行显示!登陆失败也要进行的那种页面!

求核心代码

[解决办法]
jsp登陆页面参数传递
登陆页面jsp代码如下:

<html>
<head>
<title>登陆页面</title>
</head>

<form action="login_conf.jsp" method="post">
用户登陆
用户名:<input type="text" name="uname">
密码: <input type="password" name="upassword">
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
</body>
</html>

****************************************************
验证页面jsp代码如下:
<html>
<head>
<title>用户验证页面</title>
</head>

<h1> 登陆范例-登陆成功 </h1>
<%
String name = request.getParamet("uname");
String password = request.getParameter("upassword");
if ("jn*feng".equals(name) && "2715065".equals(password)) {
%>
<jsp:forward page="login_success.jsp">
<jsp:param name="name" value="<%=name%>" />
</jsp:forward>
<%
} else {
%>
<jsp:forward page="login_failure.jsp" />
<%
}
%>

</html>

我觉得这是一个很简单的实例,不知道你是不是要一个复杂的例子,就是一进去连接数据库进行验证,通过后
让人进去,显示用户名及权限,过一段时间没有操作就视为用户离开,需要重新登入后才能操作,如果开始就没有登录进去,会显示到底是验证码有问题,还是密码不对,还是数据库无法连接。你要这种功能的话我可以直接把那个完成详细功的项目的源代码发过去

[解决办法]
你要那种不简单不复杂的倒是可以看看这个
http://hi.baidu.com/wu_shu/blog/item/651b0d29bf29a3ff99250a86.html
[解决办法]
<%@ page language="java" pageEncoding="gb2312"%>

<html>
<head>
<title>III</title>
<link href="/oa/common/Style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function login(){
document.getElementById("logindiv").style.display="inline";
}
function divcss() {
document.getElementById("logindiv").style.display="none";
}
function form1_onsubmit(){
errmsg = "";
if (document.form1.username.value=="")
errmsg += "请输入用户名!\n"
if (document.form1.userpass.value=="")
errmsg += "请输入密码!\n"
if (errmsg!="")
{
alert(errmsg);
return false;
}
}

function name_presskey() {
if (window.event.keyCode==13) {
window.event.keyCode = 9;
}
}
</script>
<style>
</style>
</head>
<body style="margin-top: 0px;background-color: #CDE5FA;" onload=SourceCheck();initial()>
<div id="logindiv" style="display:none; background-color: #eeeeee;position:absolute;width: 100%;height: 100%;top:0;left:0;font-size:20;FILTER:alpha(opacity=70);">
<form name=form1 action="login.do" method="post" onSubmit="return form1_onsubmit()">
<table align="center" style="margin-top: 20%" border="0" border="0" cellpadding="0" cellspacing="0" background="/oa/oaimages/login.jpg">
<tr>


<td width="103"> </td>
<td width="248" valign="top">
<p> </p>

<table width="200" height="115" cellpadding="0" cellspacing="0" background="/oa/oaimages/logintab.gif">

<tr>
<td width="80" height="53" valign="bottom"><div align="center">
</div></td>
<td width="117" valign="bottom"><input name="username" type="text" class="fblank" size="12" style="width:90px" value="admin" onKeyDown="name_presskey()"></td>
</tr>
<tr>
<td height="25"><div align="center"></div></td>
<td height="25"><input name="userpass" type="password" class="fblank" size="12" style="width:90px"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="imageField2" type="image" src="/oa/oaimages/blogin.gif" width="62" height="19" border="0" onclick="return " >
   
<img src="/oa/oaimages/quxiao.jpg" width="62" height="19" border="0" onclick="divcss()">
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</div>
<table style="margin-top: 0px;" width="900px" align="center">
<tr>
<td width="100%" valign="top">
<table width="100%">
<tr>
<td>
<jsp:include page="top.jsp" flush="true"></jsp:include>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" valign="top"align="center">
<table width="888" style="background-color: #D2D2D2;">
<tr>
<td valign="top">
<table width="248" style="background-color: white" >
<tr>
<td>优秀员工<br>优秀员工<br>优秀员工<br>优秀员工<br>优秀员工<br>优秀员工<br>优秀员工<br>优秀员工<br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br>
</td>
</tr>
</table>
</td>
<td valign="top">
<table width="400" style="background-color: white" >
<tr>
<td>公告<br>公告<br>公告<br>公告<br>公告<br>公告<br>公告<br>公告<br>公告<br></td>
</tr>
<tr>
<td>最新制度<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br>


</td>
</tr>
</table>
</td>
<td valign="top">
<table width="200" style="background-image: url(/oa/images/lianjiebeijing.jpg)" >
<tr>
<td style="width: 100;height: 100">

<table>
<tr>
<td><jsp:include flush="true" page="common/index.html" /></td>
</tr>
</table>

</td>
</tr>
<tr>
<td><a href="http://www.baidu.com"><img alt="" src="/oa/images/baidu.bmp" border="0" /></a></td>
</tr>
<tr>
<td><a href="http://www.163.com"><img alt="" src="/oa/images/wangyi.bmp" border="0" /></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

</table>
<table>
<tr>
<td width="900" valign="top">
<table width="100%">
<tr>
<td background="/oa/images/back_down.JPG" width="100%"> </td>
</tr>
<tr>
<td align="center" valign="top">版权所有 @ 侵权必究</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

读书人网 >Java Web开发

热点推荐