我正在开发一个 MVCPortlet。我的view.jsp 中有一个链接,它调用liferay 的portlet 类中的一个方法。
<portlet:actionURL var="listComplexURL" name="listComplex"/>
<a href="<%=listComplexURL%>">Comlex</a>
This is the <b>Refahi</b> portlet.
这是portlet类中对应的方法:
public void listComplex(ActionRequest actionRequest, ActionResponse actionResponse)
throws SQLException, ClassNotFoundException
{
RFH_Complex rfh_complex = new RFH_Complex();
ArrayList<Complex> complexList = rfh_complex.getComplexList();
actionRequest.setAttribute("complexList", complexList);
actionResponse.setRenderParameter("jspPage", "/complex.jsp");
}
我部署 portlet 并单击链接,但出现以下错误:
java.lang.IllegalStateException: Config 为空,请确保您的 init(config) > 方法调用 super.init(config)
即使我实现了 init() 方法并在其中调用 super.init() ,我仍然会收到此错误。
这是我的 getComplexList() 方法:
public ArrayList<Complex> getComplexList() throws ClassNotFoundException, SQLException
{
ArrayList<Complex> complexList = new ArrayList<Complex>();
ResultSet rs = dbOperation.executeQuery("SELECT * FROM rfh_complex");
while(rs.next())
{
Complex complex = new Complex(rs.getInt("PKComplexID"), rs.getString("ComplexName"),
rs.getString("ComplexCity"), rs.getInt("IsActive"));
complexList.add(complex);
}
return complexList;
}
Complex.jsp 包含这行代码:
ArrayList<Complex> complexList = (ArrayList)actionRequest.getAttribute("complexList");