我有一个带有下拉列表和 2 个文本字段的 JSP,供用户选择角色并分别输入用户名和密码。我需要获取用户选择的角色和uname
andpwd
并将其设置在 bean 中。请帮我 !!我对 Spring 很陌生。从基本的角度告诉我应该如何通过它。
如何从 JSP 获取用户名密码和角色值并使用 Java spring 在 bean 中设置?
<html>
<head>
<script type="text/javascript">
function enableTextBox() {
if (document.getElementById("dropdown").value == "Admin") {
document.getElementById("uname").disabled = false;
document.getElementById("pwd").disabled = false;
} else {
document.getElementById("uname").disabled = true;
document.getElementById("pwd").disabled = true;
}
}
function doClear() {
document.getElementById("uname").value = "";
document.getElementById("pwd").value = "";
}
</script>
</head>
<body>
<table border=0 width=100% height=100%>
<tr>
<td valign="middle" align="center">
<table border="1" bordercolorlight="#C0C0C0" style="border-collapse: collapse"
bordercolor="#C0C0C0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" align="center" style="width: 400px">
<table border="0">
<tr>
<td colspan=2>
<p align="center">
<img src="images/logo.jpg" width="144" height="66">
</td>
</tr>
<td align="center" colspan=2>
<FONT COLOR=BLUE SIZE=3>Welcome</FONT>
</td>
<tr>
<td align="center" colspan=2>
<STRONG><font size="4">Auction Site </font> </STRONG><font size="4"><BR>
</font>
</td>
</tr>
<tr>
<tr align=center>
<td align="right"><b>Select your role:</b>
</td>
<td align="left">
<select name="dropdown" id="dropdown" onchange="enableTextBox();">
<option value="Admin">Admin</option>
<option value="csc">CSC Employee</option>
</select>
</td>
</tr>
<tr align=center>
<td align="right"><b>User ID:</b>
</td>
<td align="left">
<input type="text" id="uname" name="uname" value="" size="15" />
</td>
</tr>
<tr align=center>
<td align="right"><b>Password:</b>
</td>
<td align="left">
<input type=password id="pwd" name="pwd" value="" size="15" />
</td>
</tr>
<tr align=center>
<input type="submit" id="sub" name="sub" value="Submit" size="15" />
<td align="left">
<input type="button" id="clr" name="clr" value="Reset" onclick="doClear()"
/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>