type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot find any information on property “name1” in a bean of type “mytrain.formbean.UserBean1”
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:839)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1045)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1101)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3374)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
代码:
[b]UserBean1 .java 文件
package mytrain.formbean;
public class UserBean1 {
private String name1;
private String password1;
public String getName() {
return name1;
}
public void setName(String n) {
this.name1 = n;
}
public String getPassword() {
return password1;
}
public void setPassword(String p) {
this.password1 = p;
}
}
—
index.jsp 文件:
<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>
<%
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>标签访问bean; My JSP “index.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>
<!– This is my JSP page111222. –><br>
<form action=”” method=”post”>
<table>
<tr>
<td><span class=”blue10″>用户名:</span></td>
<td><input type=”text” name=”mUserName1″ size=”30″/><br></td>
</tr>
<tr>
<td><span class=”blue10″>密 码:</span></td>
<td><input type=”password” name=”mPassword1″ size=”30″/><br></td>
</tr>
<tr>
<td>
</td>
<td>
<input type=”submit” value=”submit”/>
</td>
</tr>
</table>
</form>
<jsp:useBean id=”user” class=”mytrain.formbean.UserBean1″/>
<jsp:setProperty name=”user” property=”name1″ param=”mUserName1″/>
<jsp:setProperty name=”user” property=”password1″ param=”mPassword1″/>
<hr/> <!– 水平线 –>
<hr/> <!– 水平线 –>
用户名:<jsp:getProperty name=”user” property=”name1″ />
<br>
密 码:<jsp:getProperty name=”user” property=”password1″ />
</body>
</html>
麻烦各位帮看看到底是什么问题, 本人把 UserBean1 文件和index.jsp文件中的两个变量全部改成 name 和 password 就没问题,为什么? 莫非一定要 name 和 password 吗? name1 和 password1 都不行吗?
15
20
public String getName1() {
return name1;
}
public void setName1(String n) {
this.name1 = n;
}
public String getPassword1() {
return password1;
}
public void setPassword1(String p) {
this.password1 = p;
}
5
+1