浮生以轩 浮生以轩
关注数: 6 粉丝数: 42 发帖数: 272 关注贴吧数: 31
jsp中useBean用setProperty传数据传不了怎么回事 login.jsp <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> <%@ page import="testTry.Login" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'login.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h2>用户登录</h2> <jsp:useBean id="login" class="testTry.Login" scope="session"></jsp:useBean> <jsp:setProperty name="login" property="*" /> <form method="post" action="logon.jsp"> <table> <tr> <td>账号:</td> <td><input name="userName" type="text" value=""></td> </tr> <tr> <td>密码:</td> <td><input name="passWord" type="password" value=""></td> </tr> <tr> <td colspan="2"><input type="submit" value="登录"></td> </tr> </table> </form> </body> </html> logon.jsp <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> <%@ page import="testTry.Login" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'logon.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h4>登录成功</h4> <jsp:useBean id="login" class="testTry.Login" scope="session"></jsp:useBean> 账号:<jsp:getProperty property="userName" name="login"/><br> 密码:<jsp:getProperty property="passWord" name="login"/> </body> </html> Login.java package testTry; public class Login { private String userName = ""; private String passWord = ""; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; System.out.println(userName); } public String getPassWord() { return passWord; } public void setPassWord(String passWord) { this.passWord = passWord; } } 都看了N遍了。求大神帮忙看看哪里有问题。。只是一个简单地登录传递数据。
1 下一页