如何在 jsp 页面中动态设置 <title>

How to set the <title> dynamically in jsp page

在启动 jsp 页面时,如果页面在 'teacher edition type' 中启动,我想在浏览器 window/ 选项卡顶部显示 'edition type'。 DB table 中有 3 种可用的版本,它们是 - 教师版、学生版和普通版。 在我的 JSP 代码中,我正在尝试设置并尝试从 java 操作 class 中获取 'edition type'。但是,做不到。

任何人都可以指导如何在 JSP 页面中获取版本类型

JSP代码-

<% String printEditionTyp = (String)request.getAttribute("bookEditionID"); %>

<title>Message - <%out.print(printEditionTyp); %></title>

    }

确保您在 html 的 header 标签中提供 page-tile,即在 <head> 标签内。

示例:

<html>
    <head>
        <% Long printEditionTyp = (Long) request.getAttribute("bookEditionID"); %>
        <title>Message - <%= printEditionTyp %></title>
    </head>
<body>
...
...
</body>
</html>

编辑:将 bookEditionID 类型转换为 Long 代替 String