Results 1 to 3 of 3

Thread: Freemarker login form.

  1. #1
    Join Date
    Nov 2009
    Posts
    3

    Default Freemarker login form.

    Hi experts!

    I'm currently working on a project were we use freemarker as a template language.
    Instead of using the defualt login form I have created a custom controller and a custom freemarker view which goes along with that controller

    Code:
    @Controller
    public class LoginController {
        private static final String LOGIN = "components/security/login";
    
        @RequestMapping("/security/login")
        public String login(){
    
            return LOGIN;
        }
    }
    my freemarker template:

    HTML Code:
    <form action="${rc.contextPath}/j_spring_security_check" method="post">
        <label for="username">Username</label><input type="text" id="username" name="j_username"><br/>
        <label for="password">Password</label><input type="text" id="password" name="j_password"><br/>
        <input type="submit" value="Login!">
    </form>
    my applicationContext-security.xml:

    HTML Code:
    <http>
            <logout/>
                <intercept-url pattern="/*" access="ROLE_ADMIN, ROLE_GUEST"/>
            <intercept-url pattern="/security/login" filters="none"/>
            <form-login login-page="/security/login" />
        </http>
    the login works like a charm BUT, when a user enters a wrong username or password no error messages are shown and I can't figure out how to do it. Could you please help me with that.

  2. #2
    Join Date
    Nov 2009
    Posts
    3

    Question No experts out there?

    Nobody has a clue?

  3. #3
    Join Date
    Nov 2009
    Posts
    3

    Default Well it wasn't that hard.

    Since nobody seems to know I solved it myself.

    Code:
        <#if Session.SPRING_SECURITY_LAST_EXCEPTION?? && <Session.SPRING_SECURITY_LAST_EXCEPTION.message?has_content>
            <@spring.message "login.bad.credentials"/>
        </#if>
    Last edited by jide85; Nov 13th, 2009 at 02:14 AM. Reason: code should look like could

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •