i 对闯入和 j来说是非常新的,而且我必须做一项任务,即我必须做客人笔。
but place stuck in jsp view when i amm try to iterate over arrayList in which gust message store and list is static always return null my jspview is
<body>
<a href="<s:url action="GuestBook"/>">Click </a>here for sign guest book<br/><br/>
<table>
<s:iterator value="messages">
<tr>
<td><s:property value="when"/><br/></td>
<td><s:property value="guest"/><br/></td>
<td><s:property value="message"/><br/></td>
</tr>
</s:iterator>
</table>
</body>
表格
public class GuestBookAction extends ActionSupport {
private String guest, message;
private String when = new Date().toString();
private static ArrayList<GuestBook> messages = new ArrayList<GuestBook>();
static {
messages.add(new GuestBook("1","1","1"));
messages.add(new GuestBook("2","1","1"));
messages.add(new GuestBook("3","1","1"));
messages.add(new GuestBook("4","1","1"));
messages.add(new GuestBook("5","1","1"));
}
@Override
public String execute(){
boolean add = messages.add(new GuestBook(this.getGuest(), this.getMessage(), this.getWhen()));
if (add) {
return SUCCESS;
} else {
return ERROR;
}
}
public String getGuest() {
return guest;
}
public void setGuest(String guest) {
this.guest = guest;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public ArrayList<GuestBook> getMessages() {
return messages;
}
public void setMessages(ArrayList<GuestBook> messages) {
GuestBookAction.messages = messages;
}
public static Logger getLOG() {
return LOG;
}
public static void setLOG(Logger LOG) {
ActionSupport.LOG = LOG;
}
public String getWhen() {
return when;
}
public void setWhen(String when) {
this.when = when;
}
}
If I don t iterate it works fine. thanks