现在,每次我输入 mydomain.com
时,它都会自动转到 mydomain.com/projectname/home.jsf
,这是我的登录页面。不知道为什么,我知道我仍在 session 中,这意味着我可以导航到受限页面而无需再次登录。那么,如果我输入 mydomain.com
,如果用户仍在 session 中,我该怎么做才能转到 mydomain.com/projectname/CentralFeed.jsf
而不是登录页面。这是我的粗略设计
在我的 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>
我不确定你们是否需要知道这一点,但我还有一个过滤器调用 MyFilter
,它映射到受限页面,并检查用户是否仍在 session 中,如果是,则只需chain.doFilter(req, res);
,如果没有则重定向到登录页面home.jsf
最佳答案
放入index.jsp
并放入其中
<% response.sendRedirect("desired URL"); %>
删除
<welcome-file-list>
<welcome-file>CentralFeed.jsf</welcome-file>
</welcome-file-list>
来自web.xml
关于java - JSF:将 A.jsf 设置为键入 mydomain.com 时要转到的默认页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5343086/