将请求属性传递给在 glassfish 中运行的欢迎文件

发布于 2025-01-06 13:47:50 字数 134 浏览 2 评论 0原文

有没有办法为作为 Web 应用程序的欢迎文件的 JSP 文件设置属性?我看过很多描述 web.xml 中的welcome-file 标记的用途和场景的帖子,但没有看到为关联的 HttpServletRequest 设置属性的帖子。

谢谢!

Is there a way to set attributes for a JSP file acting as the welcome-file for a web application? I've seen a lot of posts describing the purpose and and scenarios of the welcome-file tag in web.xml but nothing as far as setting attributes for the associated HttpServletRequest.

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满地尘埃落定 2025-01-13 13:47:50

通过将欢迎文件更改为指向单独 servlet 的 url 模式,我能够完成我想要做的事情。在此 servlet 的 processRequest() 方法中,我添加属性并重定向到它所指向的原始 JSP。我仍然不确定如何在不从 servlet 重定向的情况下设置属性,但有些事情告诉我它可能依赖于容器,即 glassfish 和 tomcat 可能会采取不同的做法。

I was able to accomplish what I was looking to do by changing the welcome-file to point to a url pattern of a separate servlet. Inside this servlet's processRequest() method, I add the attribute and redirect to original JSP it was pointing to. I'm still unsure of how to set attributes without redirection from a servlet, but something tells me it might be container-dependent i.e. glassfish and tomcat might do it differently.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文