0

我有所有用户的默认欢迎文件,但我需要每个组的每个欢迎文件:

<welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <security-constraint>
        <display-name>Constraint1</display-name>
        <web-resource-collection>
            <web-resource-name>EspaceAdmin</web-resource-name>
            <description/>
            <url-pattern>/faces/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>administrateur</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <display-name>Constraint2</display-name>
        <web-resource-collection>
            <web-resource-name>EspaceDrapage</web-resource-name>
            <description/>
            <url-pattern>/faces/drapage/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>chefdequipedrapage</role-name>
        </auth-constraint>

    </security-constraint>

在这里我有 2 个组,我如何为每个组设置一个新的欢迎文件??

4

1 回答 1

0

这是对我有用的解决方案:我创建了一个托管 bean 包含:

public String Login() {
        try {
            message="";
            HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
            request.login(username, password);

            if(request.isUserInRole("administrateur"))
            { setGroupname("administrateur");
                return "/admin/adminHome.xhtml";}

            else if(request.isUserInRole("chefdtype1"))
            {setGroupname("cheftype1");
                return "/type1/type1Home.xhtml";}

            else if(request.isUserInRole("cheftype2"))
            {setGroupname("cheftype2");
                return "/type2/type2Home.xhtml";}

            else {
                message= "Either Login or Password is wrong";
                return "/index.xhtml";
            }

        } catch(Exception e) {
            message= "Either Login or Password is wrong";
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Votre login ou votre mot de passe est incorrect.", ""));
        }
        return null;
    }
于 2013-06-03T15:05:54.320 回答