EL内での定数の参照方法

ずっと前に一度しらべて、無理!という結論を得たのだが、また必要な局面を迎えたのでちょっとぐぐってみた。その結果JSP 2.0 Co-Specification Leadな方が解決策を挙げてるのを発見。

1. Create a Map in the application scope and put all the constants inthere. (e.g. ${myConstantsMap.SOME_CONST})

2. Create a bean that implements java.util.Map and have it look up constants (e.g. ${constantsBean.MyConstants.SOME_CONST} would call constantsBean.get( "MyConstants" ). This would return a Map containing key/value pairs for the costants in MyConstants). This is not hard to write and could be done using introspection.

3. Create a function that looks up the constants (e.g. ${fn:constants("MyConstants.SOME_CONST" )} ). Again, The function would use introspection.

やっぱり自分でどうにかするしかないみたい。ただし、今後のJSP仕様では簡単に定数へのアクセス手段を提供するぜ!とおっしゃっておられるのでそれに期待。JSP2.0もまだ業務に使えないのに、そんなん使えるようになるのはいつの話やねん!JSP見放すぞゴルァ!!などというツッコミは入れないでおく。俺も大人だし。