How do I return a coldfusion struct from a method in a java class (in Lucee)?

拟墨画扇 提交于 2019-12-13 16:09:45

问题


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()

}

来源:https://stackoverflow.com/questions/39670241/how-do-i-return-a-coldfusion-struct-from-a-method-in-a-java-class-in-lucee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!