问题描述
我对vaadin有疑问。上载按钮不起作用。请查看代码,您可以检测到错误。服务器连接断开,显示数据时也会出现尝试重新连接的情况。
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public PasswordEncoder getpasswordEncoder(){
return new BCryptPasswordEncoder();
}
private UserDetailsServiceImpl userDetailsService;
public WebSecurityConfig(final UserDetailsServiceImpl userDetailsService) {
this.userDetailsService = userDetailsService;
}
@Override
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable();
http.headers().disable();
http.authorizeRequests()
.antMatchers("/hello").authenticated()
.antMatchers("/for-admin").hasRole("ADMIN")
.antMatchers("/upload").permitAll()
.antMatchers("/gallery").hasAnyRole("ADMIN","USER")
.antMatchers("/for-user").hasRole("USER")
.and()
.formLogin().defaultSuccessUrl("/hello");
}
}
@Route("upload")
class UploadGui extends VerticalLayout {
private ImageService imageService;
public UploadGui(ImageService imageService) {
this.imageService = imageService;
Label label = new Label();
TextField textField = new TextField();
Button button = new Button("upload");
button.addClickListener(clickEvent ->
{
String uploadImage = imageService.uploadFileAndSavetoDb(textField.getValue());
Image image = new Image(uploadImage,"empty");
label.setText("Upload complete");
add(label);
add(image);
});
add(textField);
add(button);
}
}
当我转到端点/上载时,此消息弹出。我没有点击按钮。 Imageservice还可以,在一切正常之前,我没有在这些类中进行任何更改。添加与图像无关的新类时出现了问题。
当我转到端点时,上载控制台显示this。 该按钮不响应单击。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)