gpt4 book ai didi

java - JSP EL 自动同步?

转载 作者:行者123 更新时间:2023-12-02 08:03:58 25 4
gpt4 key购买 nike

假设应用程序范围内有一个名为 applicationPropertys 的 bean,并且使用 EL 在 JSP 中访问它,

${applicationPropertys.someProperty}

访问会自动同步吗?如果不是怎么实现?

其次,如果 bean applicationPropertys 中的所有属性都由 ServletContextListener 设置一次,并且在此之后全部只读,那么我相信同步是不必要的。

如果同步是自动的,那么如何避免同步以提高性能呢?

我是否应该将页面所需的所有 applicationPropertys 移至 servlet Controller 中的页面范围,然后转发到 JSP 并从页面范围检索所需的属性?或者这比同步更糟糕?

最佳答案

Would access be synchronised automatically?

没有。

If not how can it be achieved?

通过将 synchronized 添加到 javabean 类的 getSomeProperty() 方法。

secondly if all the property's in the bean applicationPropertys were set once by a ServletContextListener and were all read only after that then I believe that the synchronisation would be unnecessary.

这是正确的。

So if synchronisation is automatic then how can it be avoided to improve performance?

事实并非如此,所以你不需要。

关于java - JSP EL 自动同步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8457489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com