百度了好多。好多我这样的问题,就是解决不了!太郁闷了。我就不信了。哪位前辈能来指点一下,这个问题,怎么可能解决不了呢?
运行服务器后报错:
/handlelogon.jsp (line: 11, column: 1) The value for the useBean class attribute com.fxj.bean.Answer is invalid.
一下是我的javabean 代码:
package com.fxj.bean;public class Answer {
private String uid=null;
private String passwd=null;
private String result=null;
public String getUid() {
return uid;
}
public Answer(){

}
public void setUid(String uid) {
this.uid = uid;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public String getResult() {
if(uid.equals(passwd)){
result= "welcome "+uid +"!";
}
else{
result = "please login again!";
}
return result;
}
public void setResult(String result) {
this.result = result;
}
}然后是jsp代码:<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.fxj.bean.Answer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="#ffffff">
<jsp:useBean class="com.fxj.bean.Answer" id="Answer"></jsp:useBean>
<jsp:setProperty property="uid" name="answer" />
<jsp:setProperty property="passwd" name="answer" />
<br>
<p>
<font color="blue">
<h1><jsp:getProperty property="result" name="answer" /></h1>
</font>
</p>
</body>
</html>
按照百度上说的:不带参数的构造函数,包引入,这些都做了,可是还是没用。这是郁闷至极!
求教啊!

解决方案 »

  1.   

    <jsp:useBean class="com.fxj.bean.Answer" id="Answer"></jsp:useBean>
    你这里的id属性值改为answer
    去掉<%@ page import="com.fxj.bean.Answer" %>
    编码最好改为UTF-8
    contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
      

  2.   

    大小写要注意setProperty的name属于是实例名,也就是你上面定义的Answer.
      

  3.   

    应该是你输入的类型不对,你设置的javaBean的几个属性都是String类型的,你输入的时候不能输入汉字,只能输人字符,否则就会报错