成功登录后无法重定向用户

时间:2016-01-26 12:06:37

标签: spring jsf spring-security

我正在使用primefaces和spring security 我的支持bean里面的方法运行良好。它调用用户详细信息服务并验证或拒绝登录尝试。 我的问题是重定向。在auth之后将用户重定向到所需页面的正确方法是什么?目前,我可以看到用户已通过身份验证,但仍会显示登录表单。

myRange = 5; % values in open interval [-myRange, myRange]
A = myRange*(2*rand(10) - 1);
qA = uencode(A, 3, myRange)+1;
% or, if you dont have Signal Processing Toolbox required for 'uencode'
% [~, ~, qA] = histcounts(A, -myRange:myRange/4:myRange);

% (+) create "histogram" of sum of values assigned to each bin
myHistogram = accumarray(qA(:), A(:), [8 1])

1 个答案:

答案 0 :(得分:1)

您似乎忘记在控制器方法中映射correctincorrect路径。

如果我想重定向而不是使用

return "redirect:/correct/" + user.getUserName();

并在映射此新请求的新控制器方法中处理此新请求。 或

return "redirect:/incorrect"

从处理登录请求的控制器方法返回类似的内容。

/web/WEB-INF/faces-config.xml中为JSF使用适当的导航规则:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <navigation-rule>
        <from-view-id>/index.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>incorrect</from-outcome>
            <to-view-id>/failure.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>correct</from-outcome>
            <to-view-id>/sucess.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>