jsp 中 'class' 和 'type' 属性的区别

Diffrence Between 'class' and 'type' attribute in jsp

在 jsp 我找到了 -

<jsp:useBean id="user" class="com.test.UserDetails" />  

我的意思是(如果我错了,请纠正我)-如果一个 UserDetails 实例已经存在,那么它将被分配一个 id user,如果不存在,那么一个新的UserDetails 对象已创建,并将分配 ID user

但在极少数情况下,我发现以下 <jsp:useBean>type -

 <jsp:useBean id="account" type="com.test.Account" />    

现在我的问题是 -

  1. type 在这里做什么?
  2. typeclass 有什么区别?

提前致谢。

class: instantiates the specified bean class (i.e. creates an object of the bean class) but it must have no-arg or no constructor and must not be abstract.

type: provides the bean a data type if the bean already exists in the scope. It is mainly used with class or beanName attribute. If you use it without class or beanName, no bean is instantiated.

来源:Attributes and Usage of jsp:useBean action tag