对于最新的稳定版本,请使用 Spring Framework 6.2.4

构造 函数

您可以使用new算子。您应该完全使用 限定类名称,适用于所有类型的类型,但位于java.lang包 (Integer,Float,String等)。以下示例演示如何使用newoperator 调用构造函数:

Inventor einstein = parser.parseExpression(
	"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
		.getValue(Inventor.class);

// create new Inventor instance within the add() method of List
parser.parseExpression(
	"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
		.getValue(societyContext);

APP信息