我怎么感觉struts中所定义的FormBean没什么作用呢!

zmrljl 2002-12-20 12:56:29
Formbean只使一些属性的枯燥定义,谁来说说·
...全文
80 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zmrljl 2002-12-20
  • 打赏
  • 举报
回复
baitianhai 2002-12-20
  • 打赏
  • 举报
回复
晕倒,如果你不要这么做的话,可以不这么做,不就完了,用老办法吧
zmrljl 2002-12-20
  • 打赏
  • 举报
回复
就是吗》》》太烦人!
to ccjsmile() :


怎么配置??给出格式吧
zmrljl 2002-12-20
  • 打赏
  • 举报
回复
yes
ccjsmile 2002-12-20
  • 打赏
  • 举报
回复
看来很多人对于struts的工作流程不是很了解,建议看一些相关资料。
struts1.1可以不用为每个表单都做一个forumbean了,可以在struts-config.xml里设置。
freecode 2002-12-20
  • 打赏
  • 举报
回复
它用于保存页面上的值。
确实每个页面都做一个formbean让人感觉受不了
zmrljl 2002-12-20
  • 打赏
  • 举报
回复
好像没有我要问的 。
baitianhai 2002-12-20
  • 打赏
  • 举报
回复
教程
http://www.chinajavaworld.net/non-cgi/usr/48/48_46.doc
都在这里了
http://www.chinajavaworld.net/forum/jinghua.cgi?action=list&forum=48
zmrljl 2002-12-20
  • 打赏
  • 举报
回复
那我在具体的程序中应该去如何去做呢,重写public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)或public void reset(ActionMapping mapping, HttpServletRequest request)就可以了,struts什么时候调用呢》
baitianhai 2002-12-20
  • 打赏
  • 举报
回复
看看这个例子吧,它可以用来检验用户的输入Form是否正确,基本上可以用来代替客户端的javascript功能
baitianhai 2002-12-20
  • 打赏
  • 举报
回复
package org.apache.struts.webapp.example;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public final class LogonForm extends ActionForm {

private String password = null;
private String username = null;

public String getPassword() {
return (this.password);
}

public void setPassword(String password) {
this.password = password;
}

public String getUsername() {
return (this.username);
}

public void setUsername(String username) {
this.username = username;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {
this.password = null;
this.username = null;
}


/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((username == null) || (username.length() < 1))
errors.add("username", new ActionError("error.username.required"));
if ((password == null) || (password.length() < 1))
errors.add("password", new ActionError("error.password.required"));
return errors;
}
}

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧