MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » "JspTest.jsp": org.apache.jasper.Jaspe

"JspTest.jsp": org.apache.jasper.JasperException:

www.MyException.Cn  网友分享于:2015-08-27  浏览:2559次
JSP 诡异的问题
JspRegister.jsp:(登录界面)
<%@ page contentType="text/html; charset=gb2312" %>

<html>
  <head>
  <title>JspRegister</title>
  </head>
  <body>
  <form action="JspTest.jsp" method="GET">
  <table>
  <tr><td>姓名:<input name="userName" type="text"/></td></tr>
  <tr><td>密码:<input name="userPassword" type="password" size="20"/></td></tr>
  <tr><td>年龄:<input name="userAge" type="text" size="10"/></td></tr>
  </table>
  <input type="submit" value="Submit"/>
  </form>
  </body>
</html>

JspTest.jsp:
<%@ page contentType="text/html; charset=gb2312" %>

<jsp:useBean id="user" scope="page" class="jspproject.JspTestBean">
  <jsp:setProperty name="user" property="*" />
</jsp:useBean>

<html>
  <head>
  <title>JspTest</title>
  </head>
  <body>
  注册成功:<br />
  <hr />
  使用 Bean 属性方法:<br />
  用户名:<%=user.getUserName() %><br />
  密码:<%=user.getPassword() %><br />
  年龄:<%=user.getAge() %><br />

  <hr />

  使用 getProperty:<br />
  <hr />
  使用 getProperty:<br />
  用户名:<jsp:getProperty name="user" property="userName"/><br />
  密码:<jsp:getProperty name="user" property="userPassword"/><br />
  年龄:<jsp:getProperty name="user" property="userAge"/><br />
  </body>
</html>


JspTestBean:
package jspproject;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2011</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */


public class JspTestBean {
  public String userName;
  public String userPassword;
  public int userAge;

  public void setUserName(String userName) { this.userName = userName; }
  public String getUserName() { return userName; }

  public void setPassword(String userPassword) { this.userPassword = userPassword; }
  public String getPassword() { return userPassword; }

  public void setAge(int userAge) { this.userAge = userAge; }
  public int getAge() { return userAge; }
}


为什么红色部分设置这样的字段后会提示出错并“找不到服务器”:"JspTest.jsp": org.apache.jasper.JasperException: Cannot find any information on property 'userPassword' in a bean of type 'jspproject.JspTestBean'


而将其userPassword改为password,userAge改为age却有时可以运行,但有时却“找不到服务器”为什么呢??我是用JBuilder 2006的,太诡异了。。


------解决方案--------------------
Java code

public class JspTestBean {
  public String userName;
  public String userPassword;
  public int userAge;

  public void setUserName(String userName) { this.userName = userName; }
  public String getUserName() { return userName; }

  public void setUserPassword(String userPassword) { this.userPassword = userPassword; }
  public String getUserPassword() { return userPassword; }

  public void setUserAge(int userAge) { this.userAge = userAge; }
  public int geUsertAge() { return userAge; }
}

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有