0

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

包: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 和服务器本身,但都没有帮助。对此问题的任何见解都非常感谢。

4

2 回答 2

2

为了成为一个有效的 Java Bean,一个类必须有一个无参数的构造函数(它也可以有其他的构造函数,但必须至少有一个无参数的构造函数)。尝试将这样的构造函数添加到您的Folders类中。

于 2013-02-27T14:59:28.237 回答
0

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

于 2013-02-18T18:35:54.567 回答