首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决: IllegalStateException: Config为空,请确保init(config)方法调用super.init(config)

如何解决: IllegalStateException: Config为空,请确保init(config)方法调用super.init(config)
EN

Stack Overflow用户
提问于 2012-06-25 09:17:22
回答 1查看 864关注 0票数 0

我正在开发一个MVCPortlet。我的view.jsp中有一个链接,它在救生圈中调用portlet类中的一个方法。

代码语言:javascript
复制
<portlet:actionURL var="listComplexURL" name="listComplex"/>    
<a href="<%=listComplexURL%>">Comlex</a>
This is the <b>Refahi</b> portlet.

这是portlet类中的对应方法:

代码语言:javascript
复制
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()方法:

代码语言:javascript
复制
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包含以下代码:

代码语言:javascript
复制
ArrayList<Complex> complexList = (ArrayList)actionRequest.getAttribute("complexList");
EN

回答 1

Stack Overflow用户

发布于 2012-06-25 09:53:43

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11186487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档