覆盖ResourceHttpRequestHandler Spring MVC

时间:2017-06-03 14:53:49

标签: java spring spring-mvc

我试图在Spring MVC应用程序中覆盖ResourceHttpRequestHandler。

到目前为止,我有以下课程:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="the_champ_login_ul">
  <li>
    <i class="theChampLogin theChampFacebookBackground theChampFacebookLogin" alt="Login with Facebook" title="Login with Facebook" style="display: block;"><ss class="theChampLoginSvg theChampFacebookLoginSvg"></ss></i></li>
  <li>
    <i class="theChampLogin theChampTwitterBackground theChampFacebookLogin" alt="Login with Twitter" title="Login with Twitter" style="display: block;"><ss class="theChampLoginSvg theChampTwitterLoginSvg"></ss></i></li>
</ul>

现在它应该只调用超级handleRequest,所以什么都不应该改变,但是我收到了这条消息:

  

引起:java.lang.IllegalStateException:WebApplicationObjectSupport实例[ResourceHttpRequestHandler [locations = [],resolvers = [org.springframework.web.servlet.resource.PathResourceResolver@16943e88]]]不在ServletContext中运行。确保对象已完全配置!

我正在尝试覆盖,以便我可以实现一些自定义逻辑,试图找到非静态但未由控制器映射的资源,因为用户将能够为其CMS中的页面定义URL

有人可以告诉我哪里出错了吗?

由于

1 个答案:

答案 0 :(得分:2)

看起来你的ResourceHttpRequestHandlerReplacer不知道servletContext,这是很少见的,因为你是从ResourceHttpRequestHandler扩展它。尝试将此添加到您的班级

@Autowired
ServletContext servletContext;