原因是因为单元测试时没有加载 web.xml 中的:

    <!-- spring在service层获取session和request需要创建的监听器 -->
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

 

所以单元测试时如果需要用到 request 中的值的话,就用静态测试数据测试就好了~

 

相关文章:

  • 2021-12-31
  • 2021-11-24
  • 2021-08-22
  • 2021-08-03
  • 2022-12-23
  • 2021-09-23
  • 2021-11-29
  • 2021-06-27
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2021-11-04
  • 2021-11-28
相关资源
相似解决方案