我正在开发一个MVCPortlet。我的view.jsp中有一个链接,它在救生圈中调用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");发布于 2012-06-25 09:53:43
listComplex的方法签名是错误的。它只应该抛出IOException和PortletException。您应该在方法体或其他地方处理SQLException和ClassNotFoundException (我尝试让我的控制器不会抛出SQLException)。在您的情况下,不需要重写init方法。
https://stackoverflow.com/questions/11186487
复制相似问题