尝试为Spring MVC portlet设置值:actionURL portlet:param但由于某种原因EL不解析JSTL。请参阅下面的Message.java和MessageForm.java的详细信息,Message.java实现了equals()和hascode(),在WebSphere Portal Server v8.0和JDK 1.6中作为Spring MVC Portlet运行。
这是我的JSP:
<c:forEach items="${messageForm.messageList}" var="message" varStatus="status">
<HTMLWRAPPER name="Message_Repeat">
<tr sequence_class="tableRowPrimary,tableRowAlternate">
<td class="descriptionCell" width="150" align="Center"><form:hidden path="messageList[${status.index}].subject"/>
<a href='
<portlet:actionURL>
<portlet:param name="action" value="detail"/>
<portlet:param name="id" value="${message.id}"/>
</portlet:actionURL>'><c:out value="${message.subject}"/></a>
</td>
</tr>
</HTMLWRAPPER>
</c:forEach>
使用Spring MVC portlet v3.2.8及以下版本是taglibs:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
Message.java
public class Message implements Serializable {
private static final long serialVersionUID = 1L;
Integer id;
String type;
String subject;
String receiveDate;
String expireDate;
boolean readFlag;
boolean deleteFlag;
String body;
ArrayList<Attachment> attachmentList;
Integer attachmentCount;
String toAddress;
String fromAddress = "From Online";
public String getToAddress() {
return toAddress;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String getFromAddress() {
return fromAddress;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
public ArrayList<Attachment> getAttachmentList() {
return attachmentList;
}
public void setAttachmentList(ArrayList<Attachment> attachmentList) {
this.attachmentList = attachmentList;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Integer getAttachmentCount() {
return attachmentCount;
}
public void setAttachmentCount(Integer attachmentCount) {
this.attachmentCount = attachmentCount;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getReceiveDate() {
return receiveDate;
}
public void setReceiveDate(String receiveDate) {
this.receiveDate = receiveDate;
}
public String getExpireDate() {
return expireDate;
}
public void setExpireDate(String expireDate) {
this.expireDate = expireDate;
}
public boolean isDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(boolean deleteFlag) {
this.deleteFlag = deleteFlag;
}
public boolean isReadFlag() {
return readFlag;
}
public void setReadFlag(boolean readFlag) {
this.readFlag = readFlag;
}
@Override
public boolean equals(Object object) {
boolean result = false;
if (object == null || object.getClass() != getClass()) {
result = false;
} else {
Message message = (Message) object;
if (this.getType() == message.getType()
&& this.getId() == message.getId()) {
result = true;
}
}
return result;
}
@Override
public int hashCode() {
int hash = 3;
hash = 7 * hash + this.id.hashCode();
hash = 7 * hash + this.subject.hashCode();
return hash;
}
}
MessageForm.java
public class MessageForm implements Serializable {
private static final long serialVersionUID = 1L;
public ArrayList<Message> messageList = new ArrayList<Message>();
public String delMsgConf;
public String getDelMsgConf() {
return delMsgConf;
}
public void setDelMsgConf(String delMsgConf) {
this.delMsgConf = delMsgConf;
}
public ArrayList<Message> getMessageList() {
return messageList;
}
public void setMessageList(ArrayList<Message> messageList) {
this.messageList = messageList;
}
}
这是控制器:
@ActionMapping(params = "action=detail")
public void detailMessage(@ModelAttribute("messageForm") MessageForm messageForm, BindingResult result, Model model,@RequestParam(required=false, value="id") String id, ActionRequest actionRequest,ActionResponse actionResponse) throws Exception {
ArrayList<Message> messages = messageForm.getMessageList();
HttpServletRequest servletRequest = PortletUtils.getHttpServletRequest(actionRequest);
String sessionId = servletRequest.getSession().getId();
String messageId = actionRequest.getParameter("id");
打印出messageId
时,它只会将${message.id}
显示为值 - 任何想法我做错了什么?