The liferay page can be implemented using a search container tag, which is very convenient.
<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8" %> <% @ include file = "/html/base/init. JSP "%> <Table> <% portleturl = renderresponse. createrenderurl (); portleturl. setparameter ("jsppage", "/html/juneidongtaiportlet/list_dongtai.jsp"); %> <liferay-UI: search-container iteratorurl = "<% = portleturl %>" emptyresultsmessage = "there-are-no-juneidongtai" delta = "5"> <liferay-UI: search-container-Results> <% list <juneidongtai> tempresults = actionutil. getjuneidongtais (renderrequest); Results = listutil. sublist (tempresults, searchcontainer. getstart (), searchcontainer. getend (); Total = tempresults. size (); pagecontext. setattribute ("Results", results); pagecontext. setattribute ("Total", total); %> </liferay-UI: search-container-Results> <liferay-UI: search-container-rowclassname = "com. BSI. portal. model. juneidongtai "keyproperty =" juneidongtaiid "modelvar =" juneidongtai "> <Portlet: actionurl name =" viewjuneidongtai "Var =" viewurl "> <Portlet: param name = "juneidongtaiid" value = "$ {juneidongtai. juneidongtaiid} "/> </Portlet: actionurl> <liferay-UI: search-container-column-text name = "title" href = "<% = viewurl %>" property = "title"/> <liferay-UI: search-container-column-text name = "Release Date" property = "publishdate"/> </liferay-UI: search-container-row> <liferay-UI: search-iterator/> </liferay-UI: search-container> </table>
HTML \ juneidongtaiportlet \ list_dongtai.jsp
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %><%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%><%@ page import="java.util.List" %><%@ page import="com.liferay.portal.kernel.util.ListUtil" %><%@ page import="com.my.portal.model.JuNeiDongTai" %><%@ page import="com.my.portlet.ActionUtil" %><%@ page import="javax.portlet.PortletURL" %><portlet:defineObjects /><liferay-theme:defineObjects />
HTML \ base \ init. jsp
/** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */package com.bsi.portlet;import java.util.Collections;import java.util.List;import javax.portlet.RenderRequest;import com.bsi.portal.model.DianJianHuixx;import com.bsi.portal.model.JuNeiDongTai;import com.bsi.portal.model.ZhengCeFaGui;import com.bsi.portal.service.DianJianHuixxLocalServiceUtil;import com.bsi.portal.service.JuNeiDongTaiLocalServiceUtil;import com.bsi.portal.service.ZhengCeFaGuiLocalServiceUtil;import com.liferay.portal.kernel.exception.SystemException;public class ActionUtil { public static List<JuNeiDongTai> getJuNeiDongTais(RenderRequest request) { List<JuNeiDongTai> tempResults; try { tempResults = JuNeiDongTaiLocalServiceUtil.findAllJuNeiDongTais(); } catch (SystemException ex) { tempResults = Collections.EMPTY_LIST; } return tempResults; } }
package com.bsi.portlet;import java.io.IOException;import java.util.List;import javax.portlet.ActionRequest;import javax.portlet.ActionResponse;import javax.portlet.PortletException;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import com.bsi.portal.model.JuNeiDongTai;import com.bsi.portal.service.JuNeiDongTaiLocalServiceUtil;import com.liferay.portal.kernel.exception.PortalException;import com.liferay.portal.kernel.exception.SystemException;import com.liferay.portal.kernel.util.ParamUtil;import com.liferay.portal.model.User;import com.liferay.portal.util.PortalUtil;import com.liferay.util.bridges.mvc.MVCPortlet;/** * Portlet implementation class JuNeiJuNeiDongTaiPortlet */public class JuNeiDongTaiPortlet extends MVCPortlet {@Overridepublic void doView(RenderRequest renderRequest,RenderResponse renderResponse) {try {List<JuNeiDongTai> juNeiDongTaiList = JuNeiDongTaiLocalServiceUtil.getJuNeiDongTais(0, 10);renderRequest.setAttribute("juNeiDongTaiList", juNeiDongTaiList);super.doView(renderRequest, renderResponse);} catch (SystemException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} catch (PortletException e) {e.printStackTrace();}}public void viewJuNeiDongTai(ActionRequest request, ActionResponse response) {Long ID = ParamUtil.getLong(request, "juNeiDongTaiID");try {JuNeiDongTai juNeiDongTai = JuNeiDongTaiLocalServiceUtil.getJuNeiDongTai(ID);request.setAttribute("juNeiDongTai", juNeiDongTai);response.setRenderParameter("jspPage","/html/juneidongtaiportlet/view_dongtai.jsp");} catch (PortalException e) {e.printStackTrace();} catch (SystemException e) {e.printStackTrace();}}public void listJuNeiDongTai(ActionRequest request, ActionResponse response) {try {List<JuNeiDongTai> juNeiDongTaiList = JuNeiDongTaiLocalServiceUtil.findAllJuNeiDongTais();request.setAttribute("juNeiDongTaiList", juNeiDongTaiList);response.setRenderParameter("jspPage","/html/juneidongtaiportlet/list_dongtai.jsp");} catch (SystemException e) {e.printStackTrace();}}}
COM \ My \ Portlet \ juneidongtaiportlet. Java