当前位置: 代码迷 >> J2SE >> 登录页面如何判断是用户登录的还是管理员登录的?
  详细解决方案

登录页面如何判断是用户登录的还是管理员登录的?

热度:6572   发布时间:2013-02-25 00:00:00.0
登录页面怎么判断是用户登录的还是管理员登录的????
<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 11pt;
font-weight: bold;
}
-->
</style>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">


</script>

</head>

<body style="background-image:url(images/admin_login_bg1.png); margin:0 auto; width:500px;">

<div style="background-image:url(images/admin_login1.png); width:500px; height:200px; margin-top:130px;">
  <form id="form1" name="form1" method="post" action="123">
  <table width="500" border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td width="250">&nbsp;</td>
  <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
  <td height="40"><div align="right" class="STYLE1">用户名:</div></td>
  <td height="40" colspan="2"><input type="text" name="user.username" style="height:25px; width:200px; font-size:15pt; font-weight:bold;" /></td>
  </tr>
  <tr>
  <td height="40"><div align="right" class="STYLE1">密&nbsp; 码:</div></td>
  <td height="40" colspan="2"><input type="password" name="user.password" style="height:25px; width:200px; font-size:15pt; font-weight:bold;" /></td>
  </tr>
  <tr>
  <td height="40"><div align="right" class="STYLE1"><input type="radio" value="0" name="user" checked="checked">员工</div></td>
  <td width="100" height="40">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="1" name="user">管理员</td>
  </tr>
  <tr>
  <td height="40">&nbsp;</td>

  <td height="40" colspan="2"><a href="#"><img src="images/admin_login_button.png"></a></td>
  </tr>
  </table>
  </form>
</div>

</body>
</html>



我这里有两个单选按钮,一个是普通用户,一个是管理员,要做的就是当我选择了员工这个按钮,登录就进去就到员工页面,同理管理员也是一样!现在的问题就是怎么做当我选择员工时,<form action="">action能够指向就是员工的action,选择管理员按钮时,action指向就是管理员action !!!!

------解决方案--------------------------------------------------------
HTML code
<img src="images/admin_login_button.png" onclick="sub();"><script>function sub(){    if(document.form1.user[0].checked){        document.form1.action="staffActionName.action"    }else{        document.form1.action="managerActionName.action"    }    document.form1.submit();}</script>
  相关解决方案