An unexpected error occured caused by exception IllegalArgumentException:
Expecting collection type [[Lmodels.Question;]
当我在浏览器上运行整个项目时,这个错误出现在 localhost 中。我不明白这个错误,我检查了以某种方式链接到类 Question 的所有其他类,但没有任何错误,整个代码没有任何编译错误。
这是模型问题的类:
package models;
import play.*;
import play.db.jpa.*;
import javax.persistence.*;
import java.util.*;
@Entity
public class Question extends Model{
public int ExerciseID;
public String theQuest;
public int marks;
public String [] choices;
@ManyToOne
public Exercise myExercise;
@OneToOne (mappedBy="question")
public ModelAn modelAnswer;
public Question (Exercise e, String quest,String [] aofc,int mark){
if(myExercise.noOfQuest<50){
int j = 0;
if (quest != null){
for(int i = 0;i<myExercise.questions.length;i++){
String tempquestion = myExercise.questions[i].theQuest;
if (quest.equals(tempquestion)){
j++;
}}
if(j == 0){
myExercise = new Exercise(e.CreatorID,e.tutID,e.noOfQuest);
myExercise.setPeopleAnswered(e.getPeopleAnswered());
theQuest = quest;
while (aofc.length<=5){
this.choices[0] = aofc[0];
this.choices[1] = aofc[1];
this.choices[2] = aofc[2];
this.choices[3] = aofc[3];
this.choices[4] = aofc[4];
}
this.marks = mark;
}
}
else{
System.out.println("no question was entered please enter a question");
}}else{
System.out.println("the max no of questions was exceeded");
}
}
public void addChoices(Question theQuest,String choice1 , String choice2, String choice3, String choice4, String choice5){
String [] tempchoices = new String[5];
tempchoices[0] = choice1;
tempchoices[1] = choice2;
tempchoices[2] = choice3;
tempchoices[3] = choice4;
tempchoices[4] = choice5;
int j = 0;
for(int i = 1; i <= 5;i++){
if(tempchoices[i] != null){
j++;
}
}
if(j<2){
System.out.println("the options entered are less than 2");
}
else{
theQuest.choices[0] = choice1;
theQuest.choices[1] = choice2;
theQuest.choices[2] = choice3;
theQuest.choices[3] = choice4;
theQuest.choices[4] = choice5;
}
}
public ModelAn getModelAnswer() {
return modelAnswer;
}
public void setModelAnswer(ModelAn modelAnswer) {
this.modelAnswer = modelAnswer;
}
public String getTheQuest() {
return theQuest;
}
public void setTheQuest(String theQuest) {
this.theQuest = theQuest;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public String[] getChoices() {
return choices;
}
public void setChoices(String[] choices) {
this.choices = choices;
}
public Exercise getMyExercise() {
return myExercise;
}
public void setMyExercise(Exercise myExercise) {
this.myExercise = myExercise;
}
}