我是 liferay 的新手,现在我正在使用 liferaycookbook 学习 Liferay。我在将对象从 porlet 发送到 jsp 页面时遇到问题,
这是我的 porlet,LibraryPortlet.java
我有一个功能:
public void searchBooks(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
String searchTerm = ParamUtil.getString(actionRequest, "searchTerm");
if (Validator.isNotNull(searchTerm)) {
try {
List<LMSBook> lmsBooks = LMSBookLocalServiceUtil
.searchBooks(searchTerm);
actionRequest.setAttribute("SEARCH_RESULT", lmsBooks);
actionRequest.setAttribute("test", "sentence to test");
actionResponse.setRenderParameter("jspPage",
LibraryConstants.PAGE_LIST);
} catch (SystemException e) {
e.printStackTrace();
}
}
}
在文件中list.jsp
,我有
List<LMSBook> booksTemp = (List<LMSBook>) request
.getAttribute("SEARCH_RESULT");
List<LMSBook> books = Validator.isNotNull(booksTemp) ? ListUtil
.copy(booksTemp) : LMSBookLocalServiceUtil.getLMSBooks(0,
LMSBookLocalServiceUtil.getLMSBooksCount());
System.out.println("test: "+ request.getAttribute("test"));
in list.jsp
,booksTemp
是null
因为 liferay 无法将我的对象从LibraryPortlet.java
jsp 发送,我尝试发送字符串“sentence to test”,但在控制台中,它显示测试:null
有谁遇到过同样的问题,请帮帮我!