search

Home  >  Q&A  >  body text

在控制层和业务层处于不同项目中时, 如何让业务层的java类调用SESSION里的信息

想在业务层所处的项目里面, 创建一个共通工具类来返回SESSION里保存的用户信息
可以实现吗?

高洛峰高洛峰2887 days ago241

reply all(5)I'll reply

  • PHPz

    PHPz2017-04-17 17:50:36

    Just write a static method and pass HttpRequest into it

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:50:36

    Or insert the session object into the method of the tool class.

    reply
    0
  • PHPz

    PHPz2017-04-17 17:50:36

    You just need to pass httpRequest in.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:50:36

    request.getSession

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:50:36

    Session is something in the Controller layer and should not be passed to the Service and Dao layers. You should extract the user information at the Controller layer and save it in the cache, and then the Service layer obtains the user information through userKey.

    reply
    0
  • Cancelreply