Struts标签例子

<body> 
  <html:form action="/User.do?type=insert" method="post">
  <bean:message key="username"/><html:text property="username"></html:text><html:errors property="username"/><br/>
  <bean:message key="password"/><html:password property="password"></html:password><html:errors property="password"/><br/>
  <html:submit value="submit"></html:submit>
<html:reset value="reset"></html:reset>
   </html:form>
  
    <html:form action="/User.do?type=delete" method="post">
    <html:text property="id"></html:text><br/>
    <html:submit value="删除"></html:submit>
    </html:form>
  </body>

 

----------------------------------Form---------------------------------------

public ActionErrors validate(ActionMapping mapping,
   HttpServletRequest request) {
  ActionErrors errors = new ActionErrors();
  if("".equals(username)||this.username==null){
   ActionError error=new ActionError("user.error.username");
   errors.add("username",error);
  }
  if("".equals(password)||this.password==null){
   ActionError error=new ActionError("user.error.password");
   errors.add("password",error);
  }
  return errors;

--------------------------------------------------------------------------------

你可能感兴趣的:(html,bean,struts)