我有一個帶有下拉和2個文本字段的JSP,供用戶選擇角色並分別輸入用戶名和密碼。我需要獲取用戶選擇的角色和uname
和pwd
並將其設置在bean中。請幫幫我 !!我對春天很新鮮..從基本上告訴我,我應該如何通過這個。從JSP獲取用戶名密碼和角色值並在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>
請首先分享JSP的代碼。 – Amber
[你有什麼嘗試?](http://www.whathaveyoutried.com/)我的意思是*除了*在互聯網上向隨機陌生人詢問是否爲你做。 –
@Amber共享JSP代碼!謝謝 – Priya