Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 JSF 2.0。我不想多次调用 setter 和 getter。你能帮我避免这种情况吗?
为什么这让你烦恼?这些电话非常便宜。
也许您在 getter/setter 中而不是在(post)构造函数和/或 action(listener)方法中错误地调用了昂贵的业务逻辑?这确实是 JSF 中一个非常常见的初学者错误。只是不要在 getter/setter 中调用业务逻辑。改为在(后)构造函数和/或操作(侦听器)方法中调用业务逻辑。Getter/setter 纯粹是为了获取和设置(已经准备好的)bean 属性。