我正在开发网站(HTML、javascript、jQuery、Ajax、css),我在服务器端使用 spring 中的基本身份验证。我在 HTTP 请求的授权标头中发送 Basic="Base64 Endcoded Username & password"。登录在正确的用户名和密码上工作正常。但是在失败时,它会向我显示输入用户名和密码的默认提示。我该怎么做才能不显示提示,而是应该得到一个错误代码。这样,我就可以显示正确的失败消息。
春季安全
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-安全-3.0.3.xsd ">
<http create-session="never">
<intercept-url pattern="/rest/user*" access="ROLE_USER" />
<logout logout-success-url="/index.jsp" invalidate-session="true" />
<http-basic />
</http>
<authentication-manager>
<authentication-provider>
<password-encoder hash="md5"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select UserName as username, Password as user_password,true
from User where username=?"
authorities-by-username-query="
select UserName as username,'ROLE_USER' from User where username=?"
/>
</authentication-provider>
</authentication-manager>