public abstract class ActionForm implements Serializable {
}
public abstract class ActionForm implements Serializable {
}
ActionForm form = null;
/**
* 根据action的name,attribute,scope属性,查找form,
* 若name为null,返回null。
* 若name不为null,先在request或session中寻找是否已存在这个form,
* 不存在即通过form-bean的type属性生成对应类的实例,并将这个类保存
* 到request或session中,然后通过BeanUtils的API,将表单的请求信息
* 灌入form对象,最后返回form对象
* @param mapping
* @param request
* @return
* @throws Exception
*/
private ActionForm processFrom(ActionMapping mapping,
HttpServletRequest request) throws Exception {
ActionForm form = null;
String name = mapping.getName();
if (name == null) {
return null;
}
String attribute = mapping.getAttribute();
if (attribute == null) {
attribute = name;
}
String scope = mapping.getScope();
if (scope == null) {
scope = "session";
}
HttpSession session = request.getSession();
if ("request".equals(scope)) {
form = (ActionForm) request.getAttribute(attribute);
} else if ("session".equals(scope)) {
form = (ActionForm) session.getAttribute(attribute);
}
if (form == null) {
FormBean bean = formBeans.findFormBean(name);
String type = bean.getType();
form = (ActionForm) Class.forName(type).newInstance();
if ("request".equals(scope)) {
request.setAttribute(attribute, form);
} else if ("session".equals(scope)) {
session.setAttribute(attribute, form);
}
}
BeanUtils.populate(form, request.getParameterMap());
return form;
<form action="reg.action"
method="post">
username:<input type="text"
name="username" value="${lf.username}"
/><br />
pwd:<input type="text"
name="pwd"/><br />
age:<input type="text"
name="age" value="${lf.age}"
/><br />
<input type="submit"
value="submit" />
上一篇:自己动手写struts2-1
下一篇:自己动手写struts3
在上一节,我们自己写的web框架,只能运行显示一个HelloWorld。现在我们对其进行一次加工
这篇文章 可作为北京尚学堂 hibernate的学习笔记再学习hibernate之前 得有一点反射的基础知识
&n
写插件刚开始以为很简单,后来发现不过就是一些面向对象和面向过程的堆积。复杂的写的思路。 以下是我学习写查看看过3个不错的链接。 http://api.jquery.com/jQuery.extend/ &
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M