You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
text/web/filterLogin.jsp

28 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 这是JSP页面的指令作用如下
- contentType="text/html;charset=UTF-8"设置该JSP页面响应的内容类型为HTML格式并且指定字符编码为UTF-8确保页面中的中文等特殊字符能正确显示与传输。
- language="java"明确该页面中使用的脚本语言是Java意味着可以在页面中嵌入Java代码片段来实现业务逻辑等功能。 -->
<html>
<head>
<title>TITLE</title>
<!-- 设置HTML页面的标题在浏览器标签页等地方会显示该标题内容 -->
</head>
<body>
<%
// 以下是一段嵌入在JSP页面中的Java代码片段用于判断当前会话session中是否存在某些特定属性。
// session.getAttribute("student")==null检查名为"student"的会话属性是否不存在值为null
// session.getAttribute("teacher")==null检查名为"teacher"的会话属性是否不存在值为null
// session.getAttribute("admin")==null检查名为"admin"的会话属性是否不存在值为null
// 整体逻辑是,只有当这三个属性在会话中都不存在时,才会执行后续的转发操作。
if (session.getAttribute("student") == null && session.getAttribute("teacher") == null && session.getAttribute("admin") == null) {
%>
<jsp:forward page = "login.jsp"/>
<!-- 这是JSP的一个动作标签<jsp:forward>),用于将请求转发到指定的页面(这里是"login.jsp"页面)。
意味着当满足上述Java代码中判断条件时当前请求会被直接转发到"login.jsp"页面浏览器地址栏的URL可能不会发生改变取决于服务器的具体配置和实现
并且后续当前JSP页面中未执行的部分代码将不会再执行控制权交给了被转发到的"login.jsp"页面。 -->
<%
}
%>
</body>
</html>