struts中的helper类的简单使用问题。 help!!!
按教程上的一个Action中如下的代码:
package app;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
public class RegisterAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
// ○1 将form 转型为RegisterForm
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();
ActionForward forward = new ActionForward();
// ○2 应用业务逻辑
if (password1.equals(password2)) {
try {
// ○3 如成功,则返回针对success 的ActionForward
UserDirectory.getInstance().setUser(username,password1);
forward = mapping.findForward("success");
} catch (UserDirectoryException e) {
forward = mapping.findForward("failure");
}
} else{
forward = mapping.findForward("failure");
}
// ○4 返回针对failure的ActionForward
return (forward);
}
}
在读到UserDirectory时出错了,显示“不能解析UserDirectory,它不是一种类型。”
可是教材上写“如果两次密码匹配○2 ,我们将用户添加到 UserDirectory 中,并返回与success 对应的ActionForward 。UserDirectory 是一个 helper 类,它记录usernames 和passwords 到一个标准的属性文件之中。”
这个helper类要如何加入,要如何设才可以用呢????