Java 从操作重定向到同一页
例如,在每个页面上,我都允许用户对自己进行授权。但在actionJava 从操作重定向到同一页,java,jsp,spring-mvc,Java,Jsp,Spring Mvc,例如,在每个页面上,我都允许用户对自己进行授权。但在actionLoginAction中,我每次都将他移动到main.jsp,因为req.getRequestURI返回包含action的url localhost:8080/reservation/LoginAction.do 这里是登录操作 HttpSession session = req.getSession(); log.debug("attempt to checkuser"); String login
LoginAction
中,我每次都将他移动到main.jsp
,因为req.getRequestURI
返回包含action的url
localhost:8080/reservation/LoginAction.do
这里是登录操作
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>
当我使用它时,我在表单中隐藏了包含实际URL(或页面)的字段。登录用户后,我使用该值重定向到最后一页
<input type="hidden" name="redirect_page" value="some_info" />
并且您可以像下面这样实际阅读它string value=req.getParameter(redirect\u page)
?是的……这就是我使用它的方式