Several common web technologies have been investigated because a company's system needs to be web-structured. Tried the next struts and understood the development process of struts. The following is a small example of a login attempt.
Development environment: JDK1.5.06 Struts1.2.7 NetBeans5.0 (inline Tomcat5.5.9)
1 First, use NB to create a Web project: Helo. Select whether to use the Struts1.2.7 check box.
2 Create Loginactionform.java file:
public class LoginActionForm extends ActionForm ...{
private String userName;
private String userPwd;
public String getUserName() ...{
return userName;
}
public void setUserName(String userName) ...{
this.userName = userName;
}
public void setUserPwd(String userPwd) ...{
this.userPwd = userPwd;
}
public String getUserPwd() ...{
return userPwd;
}
}
3 Create Loginaction.java File:
public class LoginAction extends Action ...{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) ...{
LoginActionForm loginForm = (LoginActionForm) form;
String forword="success";
System.out.println("Name:" + loginForm.getUserName());
System.out.println("Passwd:" + loginForm.getUserPwd());
return mapping.findForward(forword);
}
}