たとえば、すべてのページで、ユーザーが自分自身を承認できるようにします。しかし、アクションでは、アクションを含むURLを返す
ため、毎回LoginAction
彼を移動します。main.jsp
req.getRequestURI
localhost:8080/reservation/LoginAction.do
ここはLoginAction
HttpSession session = req.getSession();
log.debug("attempt to checkuser");
String login = req.getParameter("login");
String password = req.getParameter("password");
if (loginService.checkExists(login, password)) {
session.setAttribute("enterAttr", true);
session.setAttribute("loginame", login);
return "main";
}
session.setAttribute("enterAttr", false);
return "redirect:/reservation/main.jsp";
アクションを引き起こすページを取得するには?
ページ上のフォームは次のようになります
<form action="LoginAction.do" method="POST">
<div id="table"
class="ui-widget-header ui-corner-all ui-widget-content">
<table align="center" style="width: 100%">
<tr>
<td align="center"><span
style="color: white; font-size: 20px;"><fmt:message
key="lg" /></span></td>
<td align="right"><input type="text" id="login" name="login" />
<td>
</tr>
<tr>
<td align="center"><span
style="color: white; font-size: 20px;"><fmt:message
key="paswd" /></span></td>
<td align="right"><input type="password" id="password"
name="password" /></td>
</tr>
<tr>
<td align="right" colspan="2"><input type="submit"
id="approve" style="font-size: 10px;"
value="<fmt:message key='enter'/>" /></td>
</tr>
</table>
</div>
</form>