jsp 调用bean 出错 帮帮忙吧 我要崩溃了

来源:百度知道 编辑:UC知道 时间:2024/07/02 16:58:44
jsp代码
<%@ page contentType="text/html; charset=GB2312"%>

<html>
<head>

<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="hi" class="import ch.hello" scope="page"/>
<%=hi.getString() %>
</body>
</html>

bean代码
package ch;
public class hello
{
public String toString()
{
return "Hello Jack";
}
}

提示错误是
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /test.jsp(10,0) The value for the useBean class attribute import ch.hello is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorD

改好了

package ch;
public class hello
{

public String getAsd()
{
return "Hello Jack";
}

}

<%@ page contentType="text/html; charset=GB2312"%>

<html>
<head>

<title>Insert title here</title>
</head>
<jsp:useBean id="hi" class="ch.hello" scope="page"/> 你这里错了
<body>

<%=hi.getAsd() %>
</body>
</html>

在上面你写的是getstring();
但在Bean里面你写的是tostring();
你个改一个吧!!看看对不对!