我有WPF
的简单ListView
申请。
我添加了通过ListView
将文件添加到Drag
:
ListView lv;
private void lv_Drop(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.All;
}
private void lv_DragEnter(object sender, DragEventArgs e)
{
try
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
FileAttributes attr = File.GetAttributes(files[0]);
AddFiles(files);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
private void AddFiles(string[] files)
{
// Add the files into my `ListView`.
}
问题是Drag
ListView
一个文件进入我的@Component
public class CustomLogoutHandler implements LogoutHandler {
@Autowired
private SessionRegistry sessionRegistry;
@Override
public void logout(HttpServletRequest httpServletRequest, httpServletResponse httpServletResponse, Authentication authentication) {
...
httpServletRequest.getSession().invalidate();
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
//redirect to login
httpServletResponse.sendRedirect("/");
List<SessionInformation> userSessions = sessionRegistry.getAllSessions(user, true);
for (SessionInformation session: userSessions) {
sessionRegistry.removeSessionInformation(session.getSessionId());
}
}
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public SessionRegistry sessionRegistry() {
if (sessionRegistry == null) {
sessionRegistry = new SessionRegistryImpl();
}
return sessionRegistry;
}
@Bean
public static ServletListenerRegistrationBean httpSessionEventPublisher() {
return new ServletListenerRegistrationBean(new HttpSessionEventPublisher());
}
@Bean
public ConcurrentSessionControlAuthenticationStrategy concurrentSessionControlAuthenticationStrategy() {
ConcurrentSessionControlAuthenticationStrategy strategy = new ConcurrentSessionControlAuthenticationStrategy(sessionRegistry());
strategy.setExceptionIfMaximumExceeded(true);
strategy.setMessageSource(messageSource);
return strategy;
}
}
后触发事件的次数超过几次,因此相同的文件多次添加到列表中。
这种行为会发生什么?