Spring boot can I replace ResourceHttpRequestHandler with my own implementation?

时间:2017-04-06 16:56:56

标签: spring spring-mvc spring-boot

I am running into this issue since I have an app that has restful services but I need to serve up some static ones too. In this app I also use the EnableSwagger2 annotation. It looks like this class is public and I could subclass it but I am not sure how to configure that. My goal is to override this line so I can have control over 404s.

1 个答案:

答案 0 :(得分:2)

所以我终于做到了这一点,它成功地为我工作。配置让我有点但是在这里。假设您将一个名为ResourceHttpRequestHandler的{​​{1}}子类化。在我的CustomResourceHandler中,这正确地连接了它:

Application.java
  • 这个Answer帮助我正确配置了映射器。
  • 这个Answer about context帮助我在我的处理程序中正确设置了位置。我用不同的方式设置它们,但是我的所有资源都没有100%正常工作