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方法

 

 

或者改成这种形式:


    useroper
    showAllForum

    ${flag}
   

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

 

还有一种方法:

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

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

return "stuInfoList":

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

${urlStuOper}


   return "stuInfoList";

 

你可能感兴趣的:(java,WEB)