【问题标题】:Spring MVC using custom HttpServletRequestSpring MVC 使用自定义 HttpServletRequest
【发布时间】:2015-05-19 01:08:29
【问题描述】:

我已经创建了自己的 HttpServletRequest 类(我只覆盖了其中的 1 个方法)但我不知道如何让 spring 使用该类?

【问题讨论】:

  • 你想在哪里使用它?你想让你的 servlet 容器使用你的 HttpServletRequest 类吗?
  • 不清楚你想要什么行为。
  • @Alexander 是的,我愿意。我希望 servlet 使用我的自定义 HttpServletRequest 类。但我不知道如何让 spring 做到这一点。
  • @BalusC 我只需要覆盖 getInputStream 方法我扩展了 HttpServletRequest 但我也可以使用包装器。我不明白为什么扩展会很奇怪。

标签: java spring spring-mvc servlets


【解决方案1】:

你可以这样使用 私有@Autowired HttpServletRequest 请求;

【讨论】:

  • 这只有在 HttpServletRequest 是一个 spring bean 时才有效!
猜你喜欢
  • 2014-01-13
  • 2013-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 2017-03-22
相关资源
最近更新 更多