我正在开发一个示例 portlet,它应该显示用户在以管理员身份登录 luminus 门户时登录,而学生登录时只能看到自己并在我的代码中不断遇到错误,所以我不知道如何解决这些问题
overridden method does not thrown exception
这是我添加时得到的 portlet 代码PersonException
package com.test;
import javax.portlet.GenericPortlet;
import javax.portlet.ActionRequest;
import javax.portlet.RenderRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderResponse;
import javax.portlet.PortletException;
import java.io.IOException;
import javax.portlet.PortletRequestDispatcher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sghe.luminis.person.entity.Person;
import com.sghe.luminis.person.exception.PersonException;
import com.sghe.luminis.person.services.PersonService;
import java.util.List;
import java.io.Writer;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* WebApplication6 Portlet Class
*
*
*/
public class WebApplication6 extends GenericPortlet {
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
}
private static final Log cLog = LogFactory.getLog( WebApplication6.class );
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException, PersonException {
PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/WebApplication6_view.jsp");
dispatcher.include(request, response);
response.setContentType("text/html");
PersonService personService = PersonServiceFactory.instance().getPersonService();
List<Person> persons = personService.fetchPagedPersons( "givenname", "", 10, "1" );
cLog.debug( "We have " + persons.size() + " people." );
}
}
这是/WEB-INF/jsp/WebApplication6_view.jsp
我作为示例使用的代码
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "=//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineObjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
<%@page import="java.util.List"%>
<%@page import="com.sghe.luminis.person.entity.Person" %>
<%
List<Person> persons = (List<Person>)renderRequest.getPortletSession().getAttribute("PERSON_LIST");
%>
<html>
<head>
<meta http=equiv="Content=Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Person List</h1>
<table class="summit2" border="1 padding="2px">
<theader>
<th>Display Name</th>
<th>Login Id</th>
<th>Person Id</th>
</theader>
<% for (Person person: persons) {%>
<tr>
<td><%= person.getDisplayName() %></td>
<td><%= person.getLoginId() %></td>
<td><%= person.getPersonId() %></td>
</tr>
<% } %>
</table>
</body>
</html>