-----------SayHelloBean.html
<html>
<head>
<title>基本数据输出</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<div align="center">
<p>请输入您的数据</p>
<form method="post" action="SayHelloBean.jsp">
<p>姓名 <input type="text" name="name">
   性别<select name="sex">
       <option value="先生">先生</option>
       <option value="小姐">小姐</option>
      </select></p>
<p>
<input type="submit" name="Submit" value="送出"></p></form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</body>
</html>-----------------------SayHelloBean.jsp
<%@ page language="java" %>
<%@ page import="Hello.HelloBean" %>
<jsp:useBean id="Test" class="HelloBean" scope="request">
     <jsp:setProperty name="Test" property="name"/>
 <jsp:setProperty name="Test" property="sex"/>
</jsp:useBean><html>
<head>
<title>HelloBean</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF">
<p>&nbsp;</p>
<p align="center">
<font size="4">Hello
<font color="#0000FF"><b>
<%=Test.getName() %>
</b></font>
<%=Test.getSex() %>
你好! </font></p>
</body>
</html>
package Hello;
public class HelloBean {
private String name="";
private String sex="";
public HelloBean(){
}

public void setName(String name){
this.name= name;
}

public String getName(){

return this.name;
}
public void setSex(String sex){
this.sex= sex;
}

public String getSex(){

return this.sex;
}
}出现如下问题:
Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /SayHelloBean.jsp(3,0) The value for the useBean class attribute HelloBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)

解决方案 »

  1.   

    <jsp:setProperty name="Test" property="name"/>
    <jsp:setProperty name="Test" property="sex"/>改成<jsp:setProperty name="Test" param="name"/>
    <jsp:setProperty name="Test" param="sex"/>
      

  2.   

    <jsp:setProperty name="Test" property="name"/>
    是不是应该写成:
    <jsp:setProperty name="Test" property="name" value ="xxxxx"/>
      

  3.   

    <jsp:setProperty name="Test" param="name"/>
    <jsp:setProperty name="Test" param="sex"/><jsp:setProperty name="Test" property="name"/>
    <jsp:setProperty name="Test" property="name" value ="*"/>
     这两种方式都可以啊?
      

  4.   


    <%
    Test.setName(request.getParameter("name"));
    Test.setSex(request.getParameter("sex"));
    %>
    就可以了
      

  5.   

    楼主:错误指你的bean无法找到。<jsp:useBean id="test" class="Hello.HelloBean" scope="request"/>
    <jsp:setProperty name="test" property="*"/>使用jsp:useBean时,class要给出bean的全名,包括包。
      

  6.   

    借光:路过的各位,帮忙看看这几个帖子,看怎么解决;)
    谢谢啦!关于客户端页面从数据库中读取大量图片的问题
    http://community.csdn.net/Expert/TopicView3.asp?id=4816106乱码还原问题!
    http://community.csdn.net/Expert/TopicView3.asp?id=4813786关于javabean反射代理的问题
    http://community.csdn.net/Expert/TopicView3.asp?id=4813935大家帮忙顶顶!
      

  7.   

    <jsp:useBean id="Test" class="Hello.HelloBean" scope="request"/>
    <%
    Test.setName(request.getParameter("name"));
    Test.setSex(request.getParameter("sex"));
    %>
      

  8.   

    我知道错在哪里了
    <jsp:useBean id="Test" class="HelloBean" scope="request">
    改成
    <jsp:useBean id="Test" class="Hello.HelloBean" scope="request">
    就OK了