用SOA架构OA的时候,jsp页面是由专门的模板生成,通过生成的jsp页面要完成增删改查等操作。
表单的信息都有专门的表保存(内容类别表),保存着数据库中所有的表单信息,如表单的名称,表单所拥有的字段,字段别名,字段类型,字段长度等信息。
用模板生成表单也应的页面,当然在内容类别表中查询表单中对应的字段,用java代码拼JSP文件,但是为了新增时Action抓取数据方便,这里我们用到了Properties。所有表单的值都用这个Properties属性来抓取,看实例吧!
Form表单
public class PersonForm extends ActionForm {
public PersonForm()
{
System.out.println("初始化Action");
display = new Properties();
display.setProperty("name", "gu_zdong");
}
private [color=red]Properties [/color]display;
public Properties getDisplay()
{
return display;
}
public void setDisplay(Properties display)
{
System.out.println("display is "+display.toString());
this.display = display;
}
}
jsp页面
<html>
<head>
<base href="<%=basePath%>">
<title>index</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
td
{
font-size:13px;
}
</style>
</head>
<body>
<html:form action="/person.do" method="post">
<table align="center">
<tr>
<td>姓名</td>
<td>
<html:text property="display(name)"></html:text>
</td>
</tr>
<tr>
<td>电话</td>
<td>
<html:text property="display(phone)"></html:text>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<html:submit value="提交"></html:submit>
</td>
</tr>
</table>
</html:form>
</body>
</html>
Action
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
PersonForm person = (PersonForm)form;
Properties p = person.getDisplay();
System.out.println(p.toString());
return null;
}
运行的jsp界面
姓名展现是因为在form的构造方法中,初始化了个值。
如果在电话上填写 1111111111
运行效果:
{phone=1111111111, name=gu_zdong}