JiveJdon Community Forums
在线303人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » 开源项目大家谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 2 回复 / 1
 发表新帖子   回复该主题贴
hwangita

悄悄话
发表文章: 21
注册时间: 2007年03月27日 22:52
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修改过]
banq

悄悄话
发表文章: 9528
注册时间: 2002年08月03日 17:08
回复:Struts中的Action跳转问题!附关键代码 2007年04月23日 13:44 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
>运行到action后,应该跳转,会停在以空白页面
说明action没有被执行,使用Eclipse+JbossIDE的断点调试可以跟踪执行步骤,或log4j输出.

附带jsessionid是和cookie有关,暂时不管.
hwangita

悄悄话
发表文章: 21
注册时间: 2007年03月27日 22:52
re:Struts中的Action跳转问题!附关键代码 2007年04月24日 20:34 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
问题已经解决,我快疯掉了,
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response )
我开始把HttpServletRequest和HttpServletResponse的位置写反了,
应该是HttpServletRequest在前面,唉,浪费不少时间,!
这个主题有 2 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  每2分种自动备份发贴内容Ctrl-V粘贴取出,提问题前先查询标签列表

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com

anti spam