jsp,帮我运行一下吧!!在我机器上总报错!追加!!!

来源:百度知道 编辑:UC知道 时间:2024/06/18 04:38:02
两个文件bean2.java和test.jsp。tomcat、eclipse、jdk环境

bean2.java如下:
package bean;

public class bean2 {
public bean2(){}
public void wr()
{
System.out.println("congratulations");
}
}

test.jsp如下:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<jsp:useBean id="bean2" class="bean.bean2" scope="page"></jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%bean2.wr(); %>
</body>
</html>

报错:Unable to load class for JSP
多刷新几遍变成:The value for the useBean class attribute

程序本身没有问题
是不是tomcat没装好..

jsp加载错误啦。。可能是jsp有些包包么有。。所以你的jsp:userBean就不能用。。提示你这个bean2不可识别。

package bean;

public class bean2 {

public bean2() {
str="configuration";
}

String str;

public String getStr(){
return str;
}
}

<%@ page language="java" contentType="text/html; charset=GB2312"
pageEncoding="GB18030"%>
<jsp:useBean id="bean2" class="bean.bean2" scope="page"></jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%=bean2.getStr()%>
<br/>
<jsp:getProperty name="bean2" property="str"