I have a jsp page in struts like this:
<%@taglib prefix="s" uri="/struts-tags" %>
<s:if test="#session.variablename == null" >
**<s:action name="loginForm" />**
</s:if>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
</head>
<body>
<h1>Hello World!</h1>
<s:a href="doctorLogout">Logout</s:a>
<s:include value="/WEB-INF/doctor/doctorFooter.jsp" ></s:include>
If session
is not set, I need to redirect this page to an action in the struts.xml
page. I have tried the <jsp:forward />
tag instead of <s:action />
, but the jsp redirects to the error page. Does this have any solution? Does any redirect tag exist in struts2?
IMO this kind of work belongs in an interceptor, or at worst, a base action class. This kind of logic in a JSP makes testing more difficult.
Struts 2 does not have a redirect tag; use JSTL's <c:redirect>
tag if you're going to put that kind of logic in a JSP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.