我一直在尝试借助这个小教程使用多个操作开发 Portlet来调用 portlet 的方法“signinAction” 。但是当我尝试这样做时,我得到Portlet 暂时不可用错误。我在 Tomcat 的服务器控制台中看不到任何东西。此外,当我使用 processAction() 时,我没有收到错误消息。我不知道出了什么问题。
JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:actionURL var="signinAction" name="signinAction">
</portlet:actionURL>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body onload="load()" id="body1">
<form action="<%=signinAction.toString() %>" name="signinForm" method="post" onsubmit="return signin(this)">
<center>
<div class="div-upside-down" id="div-style">
<table width="95%">
<tr>
<td colspan="3"><p class="pp"></p>
</td>
</tr>
<tr>
<td id="td1">
<input type="text" id="email" name="email" placeholder="Email" />
<p id="one"></p>
</td>
<td id="td2">
<input type="password" id="password" name="password" placeholder="Password" />
<p id="one"></p>
</td>
<td id="td3">
<input type= "submit" name= "submit" value="Login"/>
<p id="one"></p>
</td>
</tr>
</table>
</div>
</center>
</form>
</html>
小门户:
public class HelloWorldPortlet extends GenericPortlet {
ThemeDisplay td;
public void signinAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException{
long companyId=10154;
String email = actionRequest.getParameter("email");
String password = actionRequest.getParameter("password");
try
{
int authResult = 0;
long userId = 0;
Company company = PortalUtil.getCompany(actionRequest);
Map headerMap = new HashMap();
Map parameterMap = actionRequest.getParameterMap();
authResult = UserLocalServiceUtil.authenticateByEmailAddress(company.getCompanyId(), email, password,headerMap, parameterMap, null);
userId = UserLocalServiceUtil.getUserIdByEmailAddress(company.getCompanyId(), email);
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
String screenId = user.getScreenName();
td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
MethodKey key = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
PortalClassInvoker.invoke(false, key, new Object[] { PortalUtil.getHttpServletRequest(actionRequest), PortalUtil.getHttpServletResponse(actionResponse),screenId, password, true, CompanyConstants.AUTH_TYPE_SN});
actionResponse.sendRedirect(td.getPathMain());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
请帮忙。