春季认证

时间:2012-08-07 12:25:05

标签: java spring spring-mvc

我有一个User模型,UserServices,并且我想通过登录页面验证注册用户。
你能帮我写一下在身份验证控制器中使用的方法吗?

<fieldset><legend>Authentication</legend>
<form:form action="login.htm"  commandName="user">
    <table>
        <tr>
            <td>User Name:<FONT color="red"><form:errors
                path="userName" /></FONT></td>
        </tr>
        <tr>
            <td><form:input path="userName" /></td>
        </tr>
        <tr>
            <td>Password:<FONT color="red"><form:errors
                path="password" /></FONT></td>
        </tr>
        <tr>
            <td><form:password path="password" /></td>
        </tr>
        <tr>
            <td><input type="submit" value="Submit" /></td>
        </tr>
    </table>
</form:form>
</fieldset>

2 个答案:

答案 0 :(得分:1)

如果您已经使用spring,则可以轻松添加spring security来处理用户身份验证和权限。

答案 1 :(得分:1)

在这里,您可以找到如何向应用程序添加spring安全性的示例教程。 http://blog.rajithdelantha.com/2012/07/spring-security-part-1-sample-login.html