我正在通过 Liferay 表单发布密码并将其存储在名为“password”的会话中,当我输入正确的密码时,我现在将其设置为默认值“1234”,会话被激活,当我浏览页面时它是工作正常。
但是当我第一次发布它时,它不起作用,我需要在按钮上单击 2 次才能看到数据或转到另一个页面。
这里的任何人都可以在这方面支持我吗?这是我的完整代码:
<%
String value = BeanParamUtil.getString(article, request, "structureId");
%>
<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="SecondloginURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/journal_content/view" />
</portlet:actionURL>
<c:choose>
<c:when test="<%= value.equals(\"10801\") %>">
<%
HttpSession session1 = request.getSession(false);
out.print(session1 + "<br>");
String sessionId = session1.getId();
out.print(sessionId + "<br>");
String foo = (String) session1.getAttribute("password");
out.print(foo + "<br>");
%>
<c:choose>
<c:when test="<%= !Validator.isNull(foo) %>">
<h2>this is the second password and it's working</h2>
<div class="journal-content-article"
id="article_<%= articleDisplay.getCompanyId() %>_<%= articleDisplay.getGroupId() %>_<%= articleDisplay.getArticleId() %>_<%= articleDisplay.getVersion() %>">
<%= RuntimePortletUtil.processXML(application, request, response, renderRequest, renderResponse, articleDisplay.getContent()) %>
</div>
</c:when>
<c:otherwise>
<aui:form action="<%= SecondloginURL %>" name="auth" method="POST">
<aui:input label="Second Password" type="password" name="password" />
<aui:button type="submit" value="authenticate" onClick="location.reload(true)" />
</aui:form>
<%
String pass = request.getParameter("password");
out.println(pass+" = 1234");
%>
<c:if test="<%= Validator.equals(pass, \"1234\") %>">
<%
session1.setAttribute("password","authenticated");
%>
</c:if>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<div class="journal-content-article"
id="article_<%= articleDisplay.getCompanyId() %>_<%= articleDisplay.getGroupId() %>_<%= articleDisplay.getArticleId() %>_<%= articleDisplay.getVersion() %>">
<%= RuntimePortletUtil.processXML(application, request, response, renderRequest, renderResponse, articleDisplay.getContent()) %>
</div>
</c:otherwise>
</c:choose>
我正在对journal_content/view做一个钩子