且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Velocity模板脚本(VTL)中引发用户定义的异常?

更新时间:2023-08-23 20:39:28

context.put("exceptionThrower", new ExceptionThrower());

public class ExceptionThrower {
    public void throwUserDefined() {
        throw new UserDefinedException();
    }
}

#if ($whatever) 
$exceptionThrower.throwUserDefined()
#else
blah blah
#end