Spring security 使用带有spring security的自定义登录页时出现403禁止的错误

Spring security 使用带有spring security的自定义登录页时出现403禁止的错误,spring-security,http-status-code-403,Spring Security,Http Status Code 403,我正在学习春季安全。我已经创建了自定义登录页面并使用数据库身份验证。当我尝试登录应用程序时,出现403禁止的错误。正在将我的spring安全配置文件粘贴到下面: <security:http auto-config="true"> <security:intercept-url pattern="/login.jsp" access="hasRole('ROLE_ANONYMOUS')"/> <security:form-login login-pa

我正在学习春季安全。我已经创建了自定义登录页面并使用数据库身份验证。当我尝试登录应用程序时,出现403禁止的错误。正在将我的spring安全配置文件粘贴到下面:

<security:http auto-config="true">
    <security:intercept-url pattern="/login.jsp" access="hasRole('ROLE_ANONYMOUS')"/>
    <security:form-login login-page="/login.jsp" login-processing-url="/login"/>
    <security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
</security:http>

<security:authentication-manager>
        <security:password-encoder ref="passwordEncoder"/>
     </security:authentication-provider> -->

     <security:authentication-provider>
        <security:jdbc-user-service data-source-ref="dataSource"/>
        <security:password-encoder hash="bcrypt"/>
     </security:authentication-provider>
</security:authentication-manager>

<bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder">
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/springSecurityDB"/>
    <property name="username" value="root"/>
    <property name="password" value="password"/>
</bean>

-->
下面是我的login.jsp:

<html>
<head>
<meta charset="ISO-8859-1">
<title>My Login Page</title>
</head>
<body>
<form action="login" name="loginForm" method="POST">
    Username : <input type="text" name="username"/>
    Password: <input type="password" name="password"/>
    <input type="submit" name="submit" value="Login"/>
</form>
</body>
</html>

我的登录页面
用户名:
密码:
请让我知道我做错了什么

谢谢, 安查尔


403禁止
表示登录用户没有足够的权限。根据您上面的设置,他需要具有
角色用户
权限

因为您使用的是默认的JDBCUserService,所以它需要处理这些幕后工作。因此,请遵循模式并将“ROLE\u USER”分配给登录用户,然后重试。(例如,可能在
权限表中插入一条记录
('someUser','ROLE_USER')


403禁止
表示登录用户没有足够的权限。根据您上面的设置,他需要具有
角色用户
权限


因为您使用的是默认的JDBCUserService,所以它需要处理这些幕后工作。因此,请遵循模式并将“ROLE\u USER”分配给登录用户,然后重试。(例如,可能将一条记录
('someUser','ROLE\u USER')
插入
权限表?

您好,我的数据库表中已经有一个角色为ROLE\u USER的用户。这与spring security的登录页面配合得很好。当我提供我的自定义登录页时,它停止工作。嗨,Ken,我的数据库表中已经有一个角色为_user的用户。这与spring security的登录页面配合得很好。当我提供自定义登录页面时,它停止工作。
<security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>