Java Bean无法识别

时间:2013-02-18 17:54:39

标签: java jsp javabeans

我创建了一个包含以下信息的java bean:

package:com.mysite

类:文件夹

该文件位于ROOT / WEB-INF / classes / com / mysite / Folders.class

,电话是:

<jsp:useBean id="folders" scope="session" class="com.mysite.Folders" /> 

这是一个类,如果它帮助它'只是简单,因为我想在我做任何更复杂的事情之前启动并运行它。

public class Folders implements Serializable {

public Folders(String accountNumber, String folderName, String groupName, ArrayList<String> folderNames, ArrayList<String> groupNames) {
    this.accountNumber = accountNumber;
    this.folderName = folderName;
    this.groupName = groupName;
    this.folderNames = folderNames;
    this.groupNames = groupNames;
}

public String getAccountNumber() {
    return accountNumber;
}

public void setAccountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
}

public String getFolderName() {
    return folderName;
}

public void setFolderName(String folderName) {
    this.folderName = folderName;
}

public ArrayList<String> getFolderNames() {
    return folderNames;
}

public void setFolderNames(ArrayList<String> folderNames) {
    this.folderNames = folderNames;
}

public String getGroupName() {
    return groupName;
}

public void setGroupName(String groupName) {
    this.groupName = groupName;
}

public ArrayList<String> getGroupNames() {
    return groupNames;
}

public void setGroupNames(ArrayList<String> groupNames) {
    this.groupNames = groupNames;
}


private String accountNumber;
private String folderName;
private String groupName;
private ArrayList<String> folderNames;
private ArrayList<String> groupNames;
}

每次都有相同的结果。

错误是:

SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: /custom/folders.jsp(13,0) The value for the useBean class attribute com.mysite.Folders is invalid.

我重新启动了Tomcat和服务器本身,但都没有帮助。 非常感谢对此问题的任何见解。

2 个答案:

答案 0 :(得分:2)

为了成为有效的Java Bean,类必须具有无参数构造函数(它也可以包含其他构造函数,但必须至少具有无参数构造函数)。尝试将此类构造函数添加到Folders类。

答案 1 :(得分:0)

我认为你必须将JAR包含在你的构建路径中,不是吗!?