我已经为我的springframework RESTful服务配置了Springframework安全性(4.0)。对于浏览器启动的GET访问以及html表单,其中action = GET但对于其中method = requestMethod.POST的服务失败,无论是从浏览器提交带有action = POST的HTML表单;或从远程应用程序使用RestTemplate。Springframework安全性,无法提交POST方法的HTML表单
要查看问题,我将配置简化为以下内容。有了这个,我可以访问Method = GET的所有服务,而不会受到证书的挑战(看起来是正确的),但是接收到“accessDeniedPage”的失败(我从来没有受到过证书的挑战)
所有的服务都在“/ CouponController/**”:
@Override
protected void configure (HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/CouponController/**").permitAll()
.and().formLogin().permitAll()
.and().exceptionHandling().accessDeniedPage("/Accesses_Denied_Due_To_Security_failure");
}
如果我用下面的配置,我将访问方法的服务时的挑战凭据= get时仍然会看到访问方法= POST的服务时相同的行为:
@Override
protected void configure (HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/CouponController/**").access("hasRole('STAFF')")
.and().formLogin().permitAll()
.and().exceptionHandling().accessDeniedPage("/Accesses_Denied_Due_To_Security_failure");
}
我做错了什么?
感谢您的信息。可否请您填写关于如何为标准HTML添加隐藏字段的句子?由于HTML页面是从Restful服务的服务器返回的,因此我希望看看能否让自己远离JSP。 – user1693207
@ user1693207我已经添加了隐藏的字段示例。 – dkanejs