JSF:在输入mydomain.com时,使A.jsf成为默认页面 [英] JSF: make A.jsf a default page to go to when type mydomain.com

查看:103
本文介绍了JSF:在输入mydomain.com时,使A.jsf成为默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,每次输入 mydomain.com 时,它都会自动转到 mydomain.com/projectname/home.jsf ,这是我的登录页面。不知道为什么,我知道我仍然在会话中,这意味着我可以导航到一个受限制的页面,而无需再次登录。那么我该怎么做才能让我输入 mydomain.com ,然后转到 mydomain.com/projectname/CentralFeed.jsf

Right now, every time I type mydomain.com it would automatically go to mydomain.com/projectname/home.jsf, which is my login page. Not sure why, I know I still in session meaning that I can navigate to a restricted page without login in again. So how do I make so that if I type mydomain.com, I go to mydomain.com/projectname/CentralFeed.jsf instead of login page if the user still in session. Here is my rough design

在我的web.xml中

In my web.xml

<welcome-file-list>
    <welcome-file>CentralFeed.jsf</welcome-file>
</welcome-file-list>          
<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>jdbc-realm-scholar</realm-name>
    <form-login-config>
        <form-login-page>/home.jsf</form-login-page>
        <form-error-page>/LoginError.jsf</form-error-page>
    </form-login-config>
</login-config>
 <filter>
    <filter-name>MyFilter</filter-name>
    <filter-class>com.scholar.servlet.MyFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/CentralFeed.jsf</url-pattern>        
    <url-pattern>/TextBook.jsf</url-pattern>
    ...
</filter-mapping> 

我不确定您是否需要知道这一点,但我也有Filter调用 MyFilter ,它映射到受限制的页面,并检查用户是否仍在会话中,如果是,则只需 chain.doFilter(req,res); ,如果不是则重定向到登录页面 home.jsf

I am not sure if you guys need to know this, but I also have a Filter call MyFilter, which map to restricted page, and check if the user still in session, if so then just chain.doFilter(req, res);, if not then redirect to login page home.jsf

推荐答案

放置 index.jsp

并在其中放入

and in it put

<% response.sendRedirect("desired URL"); %>

删除

remove

<welcome-file-list>
    <welcome-file>CentralFeed.jsf</welcome-file>
</welcome-file-list>    

from web.xml

这篇关于JSF:在输入mydomain.com时,使A.jsf成为默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆