我想通过像这样的
使用Spring在<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="wrap">
<h1>Bootstrap Modal Example</h1>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".modal1">
Modal 1
</button>
</div>
<div class="modal fade modal1" tabindex="-1" role="dialog" aria-labelledby="modal1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<!-- Modal Content: begins -->
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header no-borders">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel"></h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<p class="body-message centered"><strong>Modal 1 here.</strong></p>
</div>
</div>
<!-- Modal Content: ends -->
</div>
</div>
<!---------------------->
<div class="wrap">
<h1>Bootstrap Modal Example</h1>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".modal2">
Modal 2
</button>
</div>
<div class="modal fade modal2" tabindex="-1" role="dialog" aria-labelledby="modal2" aria-hidden="true">
<div class="modal-dialog modal-lg">
<!-- Modal Content: begins -->
<div class="modal-content">
<!-- Modal Body -->
<div class="modal-body">
<div class="body-message">
<h4>Modal 2 here.</h4>
<p>How to change this background colour?</p>
</div>
</div>
</div>
<!-- Modal Content: ends -->
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
中设置alwaysReauthenticate
AbstractSecurityInterceptor
但我不想为此使用XML文件。我想在Java代码中设置此属性,可能为<bean id="filterSecurityInterceptor" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="alwaysReauthenticate" value="true"/>
...
</bean>
。
答案 0 :(得分:0)
请查看以下JavaConfig,了解如何设置属性,还可以read more about Post Processing Configured Objects in the Spring Security Documentation。
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
//..
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").permitAll()
.authenticated()
.withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
public <O extends FilterSecurityInterceptor> O postProcess(O fsi) {
fsi.setAlwaysReauthenticate(true);
return fsi;
}
}).and(); //continue from here on
}
//..
}