Struts中的Action跳转问题!附关键代码
初学struts,仿照struts in action 的第一个例子,写了个struts例子,关键是,运行到action后,应该跳转,
不管是success还是failer,总的跳转到对应的success.JSP或者 fail.jsp,
但是,当我运行后,它会停在以空白页面,地址栏中显示的是:http://localhost:8088/StrutsinAction/register.do
(偶尔还会附带:jsessionid=A134BE081612A8387FCA95C0727D073A)
为什么?盼望解答!
PS:config.xml
<action path="/register"
type="fm.Action.RegisterAction"
name="RegisterForm"
scope="request"
input="/register.jsp" >
<forward name="success" path="/success.jsp"/>
<forward name="failer" path="/fail.jsp"/>
</action>
</action-mappings>
register.jsp
<html:form action="register.do">
UserName:<html:text property="username"/><br>
enter password:<html:password property="password1"/><br>
re-enter password:<html:password property="password2"/><br>
<html:submit value="Register"/>
</html:form>
Action中的业务很简单,就是判断username等不等于admin,
if (username.equals("admin")) {
return mapping.findForward("success");
}
else {
ActionMessages messages=new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("login failer"));
this.saveMessages(request, messages);
return mapping.findForward("failer");
}
[该贴被hwangita于2007年04月23日 11:52修改过]