将请求属性传递给在 glassfish 中运行的欢迎文件
有没有办法为作为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过将欢迎文件更改为指向单独 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.