0

After a successful login with Spring Security and JSF, I cannot see the "username" attribute on the "success" page. The "success" page looks like this:

<h:body>
    Welcome, #{users.username}
    <a href='j_spring_security_logout'>logout</a>
</h:body>

After login with username "John", I expected to see "Welcome, John", but the text is "Welcome, #{users.username}" .

The login form is:

    <h:form id="loginForm" prependId="false">
        <!-- Messages must be global here, to show bad credentials -->
        <h:messages globalOnly="true"/>

        <!-- Id's must not be changed to support spring security check -->
        <h:panelGrid columns="3">
            <h:outputLabel for="j_username" value="User: * " />  
            <h:inputText id="j_username" required="true" label="username" value="#{users.username}" />  
            <h:message for="j_username"  style="color:red"/>

            <h:outputLabel for="j_password" value="Password: * " />  
            <h:inputSecret id="j_password" label="password" required="true" value="#{users.password}" />  
            <h:message for="j_password" style="color:red"/>

            <h:outputLabel for="_spring_security_remember_me" value="Remember me: " />
            <h:selectBooleanCheckbox    id="_spring_security_remember_me" />        
        </h:panelGrid>

        <h:commandButton type="submit" id="login" value="Login"
                         action="#{users.login}" />
    </h:form>

I use JSF 2.2, and the bean class is this:

@ManagedBean
@Component
@SessionScoped
public class Users implements Serializable {
    private int id;
    private String username;
    private String password;
    private int enabled;

    @Autowired
    private LoginService loginService;

    // getters and setters

    public String login() throws ServletException, IOException {
        return loginService.doLogin();
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Catalin Vladu
  • 389
  • 1
  • 6
  • 17
  • The answer was there, and the username is displayed correctly now on my application. I did not find that question before asking. And the difference was the blank page there, and here, the text "#{users.username}" was displayed. – Catalin Vladu Sep 20 '19 at 12:23
  • 1
    That's unparsed. – BalusC Sep 20 '19 at 13:36

0 Answers0