gpt4 book ai didi

java - 如何在 url 中隐藏 index.jsp

转载 作者:行者123 更新时间:2023-11-28 22:41:33 25 4
gpt4 key购买 nike

在我的 java ee 项目中,我将欢迎页面映射为

<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>

正确登录后,我转到 index.jsp。这是我的家。我需要的是在 url 中隐藏 index.jsp。仅限 localhost://EMS

通常它不会在 url 中显示 index.jsp。但有时我按下后退箭头键,最终我会转到 http://localhost:8080/EMS/index.jsp

有什么办法可以隐藏吗?我目前没有使用任何与 Java 相关的框架。我也使用 apache tomcat。

最佳答案

是的,通过使用:

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

参见“Configuring Welcome Files”。

index.jsp的开头,需要检查用户是否登录,如果没有,则重定向到login.jsp。如果您不希望用户在 URL 中看到 login.jsp,则需要 include the JSP instead .

如果你想确保用户永远不会看到index.jsp,你需要检查请求URL,当URL以结尾时重定向到/ >/index.jsp 使用 response.sendRedirect()

关于java - 如何在 url 中隐藏 index.jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31780594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com