[英]JSP how to manage welcome-file-list?
How can i redirect users to one of the pages accordingly his domain name? 如何将用户重定向到其中一个页面相应的域名?
web.xml web.xml中
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>now_see_this.jsp</welcome-file>
<welcome-file>Another.jsp</welcome-file>
</welcome-file-list>
Thanks!!! 谢谢!!!
You can 您可以
javax.servlet.Filter
) 制作一个过滤器( javax.servlet.Filter
) /
映射到/
request.getServerName()
and compare with a predefined list of domains 检查request.getServerName()
并与预定义的域列表进行比较 request.getRequestDispatcher("/someIndex.jsp").forward()
depending on the domain. request.getRequestDispatcher("/someIndex.jsp").forward()
取决于域。 However, it looks like a strange use-case, because the user will still be able to access the index files for other domains if he knows them (if they are not hidden in WEB-INF
). 但是,它看起来像一个奇怪的用例,因为如果用户知道它们(如果它们没有隐藏在WEB-INF
),用户仍然可以访问其他域的索引文件。 But without knowing your requirements I can't suggest a better solution. 但是在不知道您的要求的情况下,我无法提出更好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.