1.
LoginAction.java
public class LoginAction extends Action {
??? public ActionForward execute(
???????????????????????????? ActionMapping mapping,
???????????????????????????? ActionForm form,
???????????????????????????? HttpServletRequest request,
???????????????????????????? HttpServletResponse response)
??????????????????????????????????? throws Exception {
??????? String username = ((UserForm) form).getUsername();
??????? String password = ((UserForm) form).getPassword();
???????
???????
request.setAttribute("username", username);
???????
??????? if(username.equals("freefly") &&
????????????????? password.equals("whl")) {
??????????? return mapping.findForward("helloUser");
??????? }
???????
??????? return mapping.findForward("loginFail");
??? }
}
2.hello.jsp
<html>
<head>
<title>Hello, ${username} !</title>
</head>
<body>
<H1>Hello, ${username} !</H1>
<H1>This is your secret gift!!</H1>
</body>
</html>
posted on 2006-04-29 13:14
freefly 閱讀(153)
評論(0) 編輯 收藏 所屬分類:
struts