Comlex This is the Refahi-6ren">
gpt4 book ai didi

java - 如何解析: IllegalStateException: Config is null,请确保你的init(config)方法调用了super.init(config)

转载 作者:行者123 更新时间:2023-12-01 15:19:15 32 4
gpt4 key购买 nike

我正在开发一个 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 is null, please ensure that your init(config) >method calls 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");

最佳答案

您的 listComplex 方法签名错误。它应该只抛出 IOException 和 PortletException。您应该在方法体或其他地方处理 SQLException 和 ClassNotFoundException(我尝试让我的 Controller 永远不会抛出 SQLException)。在您的情况下无需重写 init 方法。

关于java - 如何解析: IllegalStateException: Config is null,请确保你的init(config)方法调用了super.init(config),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11186487/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com