0

http://fiddle.rythmengine.com/#/editorの Rythm エンジン フィドルを介して以下の rythm テンプレート コードを試す場合

エラーが発生します:

org.rythmengine.exception.CompileException: Unhandled exception type Exception

私が試したテンプレートは次のとおりです。

 @{
        class Field {
           String description;
           String getDescription() throws Exception {
              return description;
           }
        }
        Field field=new Field();
        field.description="test";
    }

the field description is: @(field.getDescription())

ある種の try/catch コンストラクトのドキュメントを調べ、お気に入りの検索エンジンを調べました。例外の処理方法に関するヒントが見つかりませんでした。

Rythm テンプレート コードで例外を処理するにはどうすればよいですか?

4

1 に答える 1

-1

チェックされた例外をスローしないようにする必要があります。コードを次のように変更します。

@{
        class Field {
           String description;
           String getDescription() throws RuntimeException {
              return description;
           }
        }
        Field field=new Field();
        field.description="test";
    }

the field description is: @(field.getDescription())

そして、それはうまくいくはずです

于 2016-05-16T22:38:04.770 に答える