如何重写 context.getUser()
对于我当前的项目,我想覆盖 context.getUser() 方法以返回一个扩展返回的默认对象的自定义 pojo?
我想做的原因是这样我就不必使用保存个人特定数据的 sessionScope 技术,而只需调用 context.getUser() 即可(它检查哪个用户已登录(或匿名)并检索所需的所有数据没有。
for a my current project I would like to overide the context.getUser() method to return a custom pojo which extends the default object returned?
The reason I would like to do is so that I dont have to use the sessionScope technique of saving person specific data and just can call context.getUser() instead (which checks which user is logged on (or anonymous) and retrieves all data needed without.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不会覆盖 context.getUser() - 你不知道还需要什么。您是否查看过扩展库中的 userBean 和/或 peopleBean?您可以使用它来获取所需的任何信息,然后如果您需要更多信息,或者想要创建扩展这些 bean 的自定义类,请将其作为作用域 bean 安装在您的应用程序中,然后将其用作您自己的 getUser 的基础()。
I would not override context.getUser() - you don't know what else that may require. Have you looked at the userBean and or peopleBean from the extension library? You could use that to get any information you need, then if you need more, or want to create a custom class that extends those beans, install it as a scoped bean in your application, and then use it as the base for your own getUser().