How do I return a coldfusion struct from a method

2019-07-15 00:36发布

问题:

I am writing a java class and would like to return a coldfusion struct from a method. Struct extends Map and other things. I'm not a Java programmer, so I'm not sure how to fix this. Here's the lucee java docs.

When I try to compile the following code, I get an error saying that Struct is abstract and can't be instantiated (on the line when I try to create myStruct). I've tried to create a new Map, but that's also abstract.

import lucee.runtime.type;

public class MyClass {

    public lucee.runtime.type.Struct test () {

        // I was hoping to do this, but I get an error

        lucee.runtime.type.Struct myStruct = new lucee.runtime.type.Struct();
        myStruct.put("passed", true);

        return(myStruct);

    } // test()

}