struts.xml配置转向另外一个action (type='redirect')出错

如题目:

错误如下:

java.lang.NullPointerException org.apache.struts2.dispatcher.ServletRedirectResult.isPathUrl(ServletRedirectResult.java:231) org.apache.struts2.dispatcher.ServletRedirectResult.doExecute(ServletRedirectResult.java:148) org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)

................

 

 

原因:
1、转向action写法不对
2、转向的action没有指明执行什么方法
注:此配置转向的action查询时不是默认的execute方法

 

 

或者改成这种形式:

<result name="showForumList" type="chain">
    <param name="actionName">useroper</param>
    <param name="method">showAllForum</param>

    <param name="flag">${flag}</param>
   </result>

  注意:在配置文件中从一个action跳转到另一个action要传递参数,要保证在原action中存在参数属性(这里是flag,并且要有get和set方法),在struts.xml引用时用${flag}方式

 

还有一种方法:

在原来的action中设置好参数和跳转的action,即跳转的URL作为一个参数:

urlStuOper = "stuOperAction?flag=first&type=1";

return "stuInfoList":

同样要有set和get方法,然后再配置文件里面:这样引用:

<result name="stuInfoList" type="redirect">

${urlStuOper}

</result>
   return "stuInfoList";

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值