0
我想在jsp元素中使用頁面指令值(例如,值'i'用於名稱='hidden'的文本框中),它將用於計算不成功嘗試的總次數。如何在jsp元素中使用頁面指令值?
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page session="true" %>
<html>
<head>
<title>Login Application </title>
</head>
<body>
<h2>Login Application</h2>
<s:actionerror />
<%
Integer i = (Integer)application.getAttribute("i");
if (i == null) {
i = new Integer(1);
} else {
i = new Integer(i.intValue() + 1);
}
application.setAttribute("i", i);
session.setAttribute("attemp", i);
out.println("Attemp :::::"+ session.getAttribute("attemp"));
%>
<s:form action="login.action" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="doGet" key="label.login" align="center" />
<s:textfield id="hidden" name="hidden" value="<%=i %>" />
</s:form>
</body>
</html>