2012-03-18 76 views
0

我正在使用JAAS来保护我的web应用程序。正如标题所说,问题是我得到的是保护文件夹中的主页,而不是登录页面。其实主页是我的欢迎页面。顺便说一下,当我在Web浏览器中写入URL(/myappJaas/protected/admin/homeadmin.xhtml)时,它工作正常。这是web.xml文件:为什么我得到受保护的页面而不是登录页面?

<welcome-file-list> 
    <welcome-file>/protected/admin/homeadmin.xhtml</welcome-file> 
</welcome-file-list> 
<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>admins</web-resource-name> 
     <url-pattern>/protected/admin/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>admin</role-name> 
    </auth-constraint> 
</security-constraint> 
<login-config> 
    <auth-method>FORM</auth-method> 
    <form-login-config> 
     <form-login-page>/public/login.xhtml</form-login-page> 
     <form-error-page>/public/errorlogin.xhtml</form-error-page> 
    </form-login-config> 
</login-config> 
<security-role> 
    <role-name>admin</role-name> 
</security-role> 

回答

1

您误解了<welcome-file>的用途。它应该表示目录的默认索引文件的唯一文件名。当最终用户请求目录时,该文件将呈现给最终用户。然后容器将透明地将配置的欢迎文件分发给最终用户而不发送重定向。但是,当前的URL仍然处于公共领域。

您想要发送完整的重定向。您可以通过过滤器或<meta http-equiv="refresh">中的index.xhtml欢迎文件或与假想的index.xhtml欢迎文件关联的受管bean的构造函数来实现。

相关问题