|
|
|
|
|
|
|
Struts中的Action跳转问题!附关键代码
|
2007年04月23日 11:51
|
|
|
标签列表
|
|
初学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修改过]
|
|
|
|
|
|
回复:Struts中的Action跳转问题!附关键代码
|
2007年04月23日 13:44
|
|
|
>运行到action后,应该跳转,会停在以空白页面 说明action没有被执行,使用Eclipse+JbossIDE的断点调试可以跟踪执行步骤,或log4j输出.
附带jsessionid是和cookie有关,暂时不管.
|
|
|
|
|
|
re:Struts中的Action跳转问题!附关键代码
|
2007年04月24日 20:34
|
|
|
问题已经解决,我快疯掉了, public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response ) 我开始把HttpServletRequest和HttpServletResponse的位置写反了, 应该是HttpServletRequest在前面,唉,浪费不少时间,!
|
|
|
|