http://blog.csdn.net/logi22/archive/2008/03/17/2192158.aspx
解决方案 »
- 关于项目与服务器路径的问题
- 选择一个selecte标签使另一个按钮激活
- SSH三层中有关hibernate多对一的问题,请帮帮忙解决。
- 请教个过滤器的问题
- 如何通过计算机名连接数据服务器
- 为什么用hibernate无法在数据库里建表?
- 求 Middlegen-Hibernate 中的两个配置文件!(build.xml , mssql.xml)
- Jboss3.2.6+MS sqlserver2000的数据源配制(吐血求教)
- java开源项目 Jlive
- 近日参考了各位大虾的文章,完成了java,tomcat,apcahe,eclips,lomboz,emf2,oracle,jboss的整合.
- hibernate hql语句怎么实现随机抽取数据库数据
- 关于<jsp:forword>的问题,那位高手能帮忙解决一下啊
String userName=request.getParameter("userName");
......
http://127.0.0.1:8080/ch17/createUser.do
HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if ((user.getUserName() == null) || (user.getPassword().length() < 3))
{
errors.add("password", new ActionError("error.user.password"));
}
return errors;
}struts-config里的validate属性设置的是true
userName:<html:text property="user.userName" /> <br/>
password:<html:password property="user.password" /> <br/>
age: <html:text property="user.age" /> <br/>
<html:submit property="submit"/>
</html:form>在UserForm里 public class UserForm extends ActionForm
{
private User user=new User();
public void setUserName(String userName)
{
user.setUserName(userName);
}
public String getUserName()
{
return user.getUserName();
}
public void setUser(User user)
{
this.user=user;
}
public User getUser()
{
return this.user;
}
//重新设置form
public void reset(ActionMapping mapping, HttpServletRequest request)
{
this.user = new User();
}
//form有效性判断,这里做简化处理。
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if ((user.getUserName() == null) || (user.getPassword().length() < 3))
{
errors.add("password", new ActionError("error.user.password"));
}
return errors;
}
}User.javapackage com.jspdev.ch17;
/**
*表示用户信息,它是一个值对象,被From使用
*这个对象必须提供对应的getter和setter方法
*/
public class User
{
public String userName;
public String password;
public int age;
public void setUserName(String name)
{
this.userName=name;
}
public void setPassword(String password)
{
this.password=password;
}
public String getUserName()
{
return this.userName;
}
public String getPassword()
{
return password;
}
public int getAge()
{
return this.age;
}
public void setAge(int age)
{
this.age=age;
}
}
30878363
<html:form action="createUser.do" method="GET">
userName: <html:text property="user.userName" /> <br/>
password: <html:password property="user.password" /> <br/>
age: <html:text property="user.age" /> <br/>
<html:submit property="submit"/>
</html:form> 这里写错了,红色字体部分,只需要写属性名,不需要写类名。这个属性名要和formBean中的属性名一样,同时要有getter和setter方法