私が知っていること:私たちが作成するactionformbeanはActionFormのサブクラスです
Struts アクション フォーム Bean: productbean.java Struts アクション クラス: productaction.java
productaction.java のexecute()
メソッド:- やった
{
productbean p1 = new productbean();
String n =p1.getName(); // calling the getter, that returns the product name
}
ただし、データベースに書き込まれると n は null です
この inexecute
メソッドを使用すると、すべて正常に動作します。
{
productbean p1 = (productbean)form; // downcasting of ActionForm object
String n = p1.getName();
}
私の質問は、actionclass と formbean が同じパッケージにある場合、formbean のオブジェクトを作成して、actionclass で getter 関数を呼び出すことができないのはなぜですか? なぜ ActionForm オブジェクトのダウンキャストが必要なのですか?