jsp登陆页面参数传递的问题
登陆页面login.jsp代码如下:
<html>
<head>
<title> 登陆页面 </title>
</head>
<body>
<form action= "login_conf.jsp " method= "post ">
用户登陆
用户名: <input type= "text " name= "uname "> <---参数uname
密码: <input type= "password " name= "upassword "> <---参数upassword
<input type= "submit " value= "提交 ">
<input type= "reset " value= "重置 ">
</form>
</body>
</html>
****************************************************
验证页面login_conf.jsp代码如下:
<html>
<head>
<title> 用户验证页面 </title>
</head>
<body>
<h1> 登陆范例-登陆成功 </h1>
<%
String name = request.getParameter(uname); <---出错位置
String password = request.getParameter(upassword); <---出错位置
if ( "jncaofeng ".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 " />
<%
}
%>
<body>
</html>
在Myeclipse中login_conf.jsp显示无法解析uname和upassword,这是怎么回事?
------解决方案--------------------request.getParameter( "uname ");
request.getParameter( "upassword ");
------解决方案--------------------呵呵,你的uname和upassword不加引号怎么能行呢
------解决方案--------------------将login_conf.jsp中的 String name = request.getParameter(uname); <---出错位置
String password = request.getParameter(upassword); <---出错位置
改为 String name = request.getParameter( "uname ");
String password = request.getParameter( "upassword ");
即可