我正在使用带有Spring MVC的apache tile和弹簧安全性。我创建了几个页面1. BaseLayout 2. Header.jsp 3. sidebar.jsp 4. ho strong text
me.jsp 5. showdata.jsp。
Sidebar.jsp使用bootrap导航栏设计侧边栏菜单。
登录后,每当我单击侧边栏时,我都会在页面上输入type = Forbidden,状态为403,但假设我在home.jsp中添加了侧边栏菜单链接,那么它将起作用。
Home.jsp与众不同,sidebar.jsp具有直接形式
我比较了csrf令牌也可以在春季安全性中弹跳csrf被禁用
Sidebar.jsp
<li class="nav-item">
<a class="nav-link" href="/studys/showallstudys" id="customers" >
<span data-feather="users"></span>
Customers
</a>
</div>
<script>
$(function() {
$("#customers").on("click",function(e) {
e.preventDefault(); // cancel the link itself
document.forms[0].action=this.href;
document.forms[0].submit();
});
});
</script>
</form>
SpringSecurity
http.authorizeRequests().antMatchers("/").permitAll()
.antMatchers(ActionConstants.STUDY_SHOW_ALL_STUDY).hasAnyRole("Study_Director","Prado_Admin")
.antMatchers(ActionConstants.STUDY_ADD_NEW_STUDY).hasAnyRole("Prado_Admin")
.antMatchers(ActionConstants.CLIENT_SHOW_ALL_CLIENTS).hasAnyRole("Prado_Admin")
.antMatchers(ActionConstants.CLENT_ADD_CLIENT).hasAnyRole("Prado_Admin")
.antMatchers(HttpMethod.POST,"/client/addClient").hasAnyRole("Prado_Admin")
.anyRequest().authenticated().and()
.formLogin()
.defaultSuccessUrl("/home")
.permitAll()
.usernameParameter("username").passwordParameter("password").and()
.logout().permitAll();
无论我何时单击侧栏,我都希望它必须提交posr请求并正常工作。 根据我的要求,我可以使用Apache Tile,Spring Boot 2和bootsrap