动态ActionForm DynaActionForm使用问题
目的
在页面1传送参数id
页面1的action接受这个参数并显示页面2
在页面2上显示页面通过Id在数据库中查找的值name等
我用DynaActionForm来记录这个name属性
并在页面2中使用
<bean:write name="show" property="name">
执行时报错 编译可通过
description
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
root cause
java.lang.NullPointerException
struts-config
<form-bean name="show"type="org.apache.struts.action.DynaActionForm">
<form-property name="name" type="java.lang.String" />
</form-bean>
action里这么写
DynaActionForm edFrm= (DynaActionForm)httpServletRequest.getAttribute(actionMapping.getAttribute());
String name = "tomuno";//代替数据库操作
edFrm.set( "name", name);
httpServletRequest.setAttribute( actionMapping.getAttribute(), edFrm);