rjy7 - Cornell Universityによれば、setter( "set"で始まるメソッド、またはvoidを返すメソッド)を使用しないようにReadOnlyBeansWrapperを設定することで解決できます。
@Override
protected void finetuneMethodAppearance(Class cls, Method method, MethodAppearanceDecision decision) {
// How to define a setter? This is a weak approximation: a method whose name
// starts with "set" or returns void.
if (method.getName().startsWith("set")) {
decision.setExposeMethodAs(null);
} else if (method.getReturnType().getName().equals("void")) {
decision.setExposeMethodAs(null);
} else {
Class<?> declaringClass = method.getDeclaringClass();
if (declaringClass.equals(java.lang.Object.class)) {
decision.setExposeMethodAs(null);
} else {
Package pkg = declaringClass.getPackage();
if (pkg.getName().equals("java.util")) {
decision.setExposeMethodAs(null);
}
}
}
私はそれを使用して、それは私のためにうまく動作します!
[Freemarker - 豆にのみゲッターを使用する](https://stackoverflow.com/questions/39747696/freemarker-only-use-getter-for-beans) – vinS
の可能な複製@vinSご意見ありがとうございます。 私はこの質問が私の問題を解決するとは思わない。 のhierは、メソッドsetMethodShadowsPropertyのdiscriptionです: 'あなたは を持っている場合*プロパティとmyObject.foo * テンプレートでは、その後、「FOO」と呼ばれる方法の両方が方法代わりに自身 *を返しますので、プロパティ値。これはしばしば望ましくありません。「 –
あなたの質問に対する答えが見つかったら(よくできました!)、あなた自身の答えを作る方が適切です。他の答えも読んで見るのが簡単です。 – Yunnosch