preferredDateTimeFormat

preferredDateTimeFormat

遵循以下代码:

@Component
public class ClassC extends ClassA<T> implements ClassB {

    private String preferredDateTimeFormat = null;


我的过程是在从客户端调用请求后使用此类。

对于每个请求,我都希望保留preferredDateTimeFormat值,实际上是对preferredDateTimeFormat变量进行了所有请求。

我该怎么解决?

最佳答案

在您的班级上使用@Scope且值为= request

像这样

@Component
@Scope(value="request", proxyMode =ScopedProxyMode.TARGET_CLASS)
public class ClassC extends ClassA<T> implements ClassB {

  private String preferredDateTimeFormat = null;


您可以在Spring Bean Scopes here中找到更多信息。

09-25 21:55