最简单的struts入门问题 只有我不会 80分求解 一旦解决马上结帖
nuboy 2005-03-29 07:27:27 一个简单的struts 为什么编译不过去呢 我刚学struts 对他不太了解
这个action servlet 是在在命令行里编译的 在struts里 编译方法有什么不同么
struts.jar servlet.jar 都在我的 path里了
package app;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
public class RegisterAction extends Action
{
public ActionForward perform (ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
// ①Cast the form to the RegisterForm
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();
// ②Apply business logic
if (password1.equals(password2)) {
return mapping.findForward("success");
}
else{
return mapping.findForward("failure");
}
}
// ④Return ActionForward for failure
return mapping.findForward("failure");
}
4 个错误
错误信息大概是
illegal start of type
return mapping.findForwards<"failure">
illegal start of type
return mapping.findForwards<"failure">^
can not resolve symbol
symbol: class RegisterForm
location class app.RegisterAction
RegisterForm rf=(RegisterForm)form;
strust-config.xml文件进行配置了阿 而且 我现在是编译 action 和strust-config.xml
没什么关系把
我试过了
原来 struts的自带例子在我的机器上完全可以运型 可当我编译他的 action 的时候也出线同样的错误阿
是不是我的 sturts
配置里还差什么东西阿
给我的感觉好像 程序总是无法识别ActionMapping mapping,
ActionForm form,
这两个对象阿 好像也不知道ActionForm 这个类
但是 相对应打 ActionForm 我也和他都放在了app目录下 并且 ActionForm 也编译通过阿