为什么报错如下:
org.apache.jasper.JasperException: /try.jsp(8,0) The value for the useBean class attribute com.check is invalid我都javabean为:
import java.io.*;
class check
{ private String name;
private String password;
public void setname(String name){this.name=name;}
public String getname(){return this.name;} public void setpassword(String password){this.password=password;}
public String getpassword() {return this.password;} public boolean chechright(String name)
{
if(name=="aaa")
return true;
else return false;
}
}
我的jsp为:
<%@ page contentType="text/html; charset=gb2312" language="java" import="com.*,java.util.*,java.io.*" errorPage="../error.jsp" %>
<!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=gb2312">
<title>无标题文档</title>
</head>
<jsp:useBean id="check" class="com.check" scope="request"/>
<body>
<%
String name="aaa";
boolean a=check.checkright(name);
out.println(a);
%>
</body>
</html>
org.apache.jasper.JasperException: /try.jsp(8,0) The value for the useBean class attribute com.check is invalid我都javabean为:
import java.io.*;
class check
{ private String name;
private String password;
public void setname(String name){this.name=name;}
public String getname(){return this.name;} public void setpassword(String password){this.password=password;}
public String getpassword() {return this.password;} public boolean chechright(String name)
{
if(name=="aaa")
return true;
else return false;
}
}
我的jsp为:
<%@ page contentType="text/html; charset=gb2312" language="java" import="com.*,java.util.*,java.io.*" errorPage="../error.jsp" %>
<!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=gb2312">
<title>无标题文档</title>
</head>
<jsp:useBean id="check" class="com.check" scope="request"/>
<body>
<%
String name="aaa";
boolean a=check.checkright(name);
out.println(a);
%>
</body>
</html>
check 类 需要在com包下面
check类 最好写成 class Check{...}
package com;
import java.sql.*;
import java.util.*;
import java.io.*;
======
{
if(name=="aaa")
return true;
else return false;
}
不能这样比较吧!
public boolean chechright(String name)
{
if(name.equals("aaa"))
return true;
else return false;
}
你的bean也没有在com包里面呀?