我正在使用Vaadin(7.6.1)和SpringBoot(1.3.0),我在浏览器中遇到了有关应用程序URL的问题 .
如果我打电话给“http://localhost:8080/myApp/ " everything works fine -Spring Security blocks the request, redirects to login page, and after an authentication it calls the defaultSuccessUrl (" /#!"). But if the user calls " http://localhost:8080/myApp " (without the last slash) Spring Security also works but redirects to the savedRequestUrl. In this case an error message (" failed to load the bootstrap javascript: ./vaadin/vaadinbootstrap.js ”,则会显示 .
通常我希望Spring Security重定向到savedRequestUrl,那么我该怎么办? Servlet的URL模式是我的问题吗?在this answer中有一个基于注释的WebServlet的示例,但如果这是我的问题,我应该如何将它集成到我的应用程序中?
我定义了自己的SpringVaadinServlet,它覆盖了默认的vaadinServlet bean . 我的课程看起来像这样:
@SpringBootApplication
public class MyApp
{
public static void main(String[] args)
{
SpringApplication.run(MyApp.class, args);
}
@Bean(name = "vaadinServlet")
public CustomSpringVaadinServlet springVaadinServlet()
{
return new CustomSpringVaadinServlet();
}
}
public class ServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
[...]
return application.sources(MyApp.class);
}
}
public class CustomSpringVaadinServlet extends SpringVaadinServlet
{
private static final long serialVersionUID = -6507628193889155490L;
private final static Logger LOG = LoggerFactory.getLogger(SpringVaadinServletWsi.class);
@Override
protected void servletInitialized() throws ServletException
{
super.servletInitialized();
getService().setSystemMessagesProvider(new SystemMessagesProvider()
{
private static final long serialVersionUID = -5253418651979378723L;
@Override
public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo)
{
CustomizedSystemMessages messages = new CustomizedSystemMessages();
messages.setCommunicationErrorCaption("Kommunikationsfehler");
[...]
return messages;
}
});
}
}