接收参数的时候出现了异常
个别代码:
(login.jsp)
<form action="LoginAction.action" method="post">
用户名:<input type="text" name="username"/>
密码:<input type="password" name="password"/>
书籍1:<input type="text" name="bookList[0]"/>
书籍2:<input type="text" name="bookList[1]"/>
<input type="submit" value="提交"/>
</form>
(LoginAction.java)
private UserMessage user = new UserMessage();
public String login(){
System.out.println(user.getUsername());
System.out.println(user.getBookList().get(0));
System.out.println(user.getBookList().get(1));
//..............
return SUCCESS;
}
@Override
public UserMessage getModel() {
// TODO Auto-generated method stub
return user;
}
(UserMessage.java)
public class UserMessage {
private String username;
private String password;
private List<String> bookList ;
public UserMessage() {
super();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<String> getBookList() {
return bookList;
}
public void setBookLsit(List<String> bookList) {
this.bookList = bookList;
}
}
开发工具用的是Myeclipse10。做了很多的尝试,最后发现将UserMessage中的bookList实例化就不会报错了?可以为什么呢?老师的不用实例化?