【发布时间】:2018-12-23 09:39:10
【问题描述】:
在使用 Spring Security 运行应用程序时,我在所有浏览器上都出现以下错误:
“服务器理解请求但拒绝授权”
我尝试在“spring-security.xml”文件中将角色从“ROLE_ADMIN”更改为“ROLE_USER”。
下面是“spring-security.xml”
<http auto-config="true">
<intercept-url pattern ="/admin" access = "hasRole('ROLE-USER')"/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name = "abc" password = "xyz" authorities="hasRole('ROLE-USER')" />
</user-service>
</authentication-provider>
</authentication-manager>
下面是 SpringController 类:
@Controller
public class SpringController {
@RequestMapping(value = "/")
public String homePage() {
return "HomePage";
}
@RequestMapping(value="/admin", method=RequestMethod.GET)
public String loginPage() {
return "login";
}
HomePage.jsp 和 login.jsp 页面已加载属性,但在 login.jsp 上传递凭据后出现错误:
HTTP 状态 403 - 禁止
类型:状态报告
消息:访问被拒绝
描述:服务器理解请求但拒绝 授权。
Apache Tomcat/7.0.90
【问题讨论】: