在弹簧引导的vaadin项目中使用弹簧安全性时出现问题。所以我使用一个PdfViewer插件来显示PDF文件。但是,我发现了以下错误消息:404使用弹簧引导与vaadin时的js文件
error:"Not Found"
message:"No message available"
path:"/APP/PUBLISHED/pdf.worker.js"
status:404
和我的春天的安全配置是这样的:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers()
.defaultsDisabled()
.frameOptions().sameOrigin().and()
.csrf().disable() // Use Vaadin's CSRF protection
.authorizeRequests().antMatchers("/").permitAll()
.antMatchers("/vaadinServlet/HEARTBEAT/**").permitAll()
.antMatchers("/vaadinServlet/UIDL/**").permitAll()
.antMatchers("/vaadinServlet/APP/PUBLISHED/**").permitAll()
.antMatchers("login?debug").permitAll()
.antMatchers("/#!pwdreset/*").permitAll()
.antMatchers("/pwdreset/*").permitAll()
.and()
.authorizeRequests()
.and()
.formLogin().loginPage("/#!login").permitAll()
.and()
.logout().logoutUrl("/#!login?logout").logoutSuccessUrl("/").permitAll().and()
.sessionManagement().sessionFixation().newSession();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/resources/**", "/VAADIN/**");
}
所以,检查在Chrome加载的文件,我看到一个文件夹/vaadinServlet/APP/PUBLISHED/并且有所有需要的文件。
使用没有Spring Security的插件工作正常,所以任何人有任何想法?
更新
它似乎并不涉及到Spring Security的,因为我得到了类似的行为,而在一个新的简单的项目测试附加组件。这似乎是与春季启动问题。
要重现此问题,您需要(full project for download):
- 基本春天开机+ vaadin应用骨架
- 简单的PDF和下
/webapp/files
- PdfViewer add-on在你的POM和视窗元件
- 下面编译简单的用户界面
@Theme("mytheme")
@SpringUI
@Widgetset("org.test.AppWidgetSet")
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
File file = new File(basepath.concat("/files/test.pdf"));
if (file.exists()) {
PdfViewer pdfViewer = new PdfViewer(file);
Label info = new Label("File was found!");
layout.addComponents(info, pdfViewer);
} else {
Label info = new Label("no file found!");
layout.addComponent(info);
}
setContent(layout);
}
}
- 打开铬&开发人员工具与
Network
选项卡选中,访问该应用程序,你应该看到一个请求pdf.worker.js
失败。
你能提供一个[SSCCE(http://sscce.org)来重现问题了吗?没有什么奇特的,只是一个最小的POM,UI,弹簧引导配置和发射器(主类)产生这个错误。我没有看到你的配置有什么问题,也许你可以将所有静态资源路径移动到'configure'方法中的'ignore'匹配器列表,但它不应该是一个问题。我有一个类似的设置,但我的工作正常,所以没有重现它会很难理解(至少对我来说) – Morfic
@Morfic我刚刚更新了我的问题,因为它似乎是与春季启动问题,它没有与春季安全有关。虽然创建一个例子,我得到了像我的项目一样的错误。可能你对如何解决这个问题有任何想法。 –