jspからHTMLへの変換に失敗すると、JspExceptionが発生する。
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
at _hoge._test__menu._jspService(_test__menu.java:86)
HTML生成時の例外発生ではあるが、原因は、Strutsの初期化(JSPコンテナの起動)時点で例外が発生していた為。javax.servlet.jsp.JspException: Cannot retrieve mapping for action /test/test_view at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:810) at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506) at _test._test__view._jspService(_test__view.java:86)struts-config.xmlにaction(path="/test/test_view"のもの)が無いため。
java.lang.NoSuchMethodException: Property 'itemList' has no getter method at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1180) at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:772) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
javax.servlet.jsp.JspException: Exception thrown by getter for property charactor of bean testForm at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:964) at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277) at _test._test._jspService(_test.java:163)プロパティ名「charactor」用のTestForm#getCharactor()の中で例外が発生すると、このJspExceptionになる。
javax.servlet.jsp.JspException: No getter method for property job of bean nextJob at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968) at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286) at _test._test._jspService(_test.java:256)通常のActionFormの中にpublicでない子Formを定義し、それをnextJobという名前で使用しようとしたら、こうなった…。
javax.servlet.jsp.JspException: No getter method for property itemList of bean mainForm at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968) at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277) at _test._test._jspService(_test.java:621)
FormでList型の値を返すgetterを定義し、logic:iterateにおいてそれを使っていた。JDK1.4.1ではMainForm#getItemList()が呼ばれていたのだが、JRE1.4.2_07ではこのメソッドが取得できず、上記のエラーとなった。同じ現象が出ている人がいたけど、解決方法は違った。
自分の状況では、実はsetterを定義していなかった(使われないから)。setter/getterが片方しか定義されていないか、されていてもシグネーチャーが異なる(getterの戻り値とsetterの引数が異なる)とダメな場合があるっぽい。
void setValue(List value) | ⇔ | List getValue() |
void setValue(Object[] value) | ⇔ | Object[] getValue() |
setter→ | List | Object[] | なし |
---|---|---|---|
↓getter | |||
List | set:○ | set:× | set:× |
get:○ | get:× | get:× | |
Object[] | set:× | set:○ | set:× |
get:○ | get:○ | get:○ |
void setValue(int pos, Object value) | ⇔ | Object getValue(int pos) |