Java - Struts 2:找不到结果“null”

时间:2014-08-11 15:08:37

标签: java struts2

我在动作和消息上获得了404:

结果' null'找不到

行动的映射是:

<action name="startSubmission" class="startSubmissionAction">
    <result type="redirectAction">
        <param name="actionName">uploadFile</param>
    </result>
    <result name="error">/jsp/main/bip/submssionError.jsp</result>
</action>

我尝试了各种组合 - 更明确 - 没有任何作用,最新版本:

<action name="startSubmission" class="startSubmissionAction" method="execute">
    <result name="success" type="redirectAction">
        <param name="actionName">uploadFile</param>
    </result>
    <result name="error">/jsp/main/bip/submssionError.jsp</result>
</action>

我在动作中添加了调试行,看起来它甚至没有被调用 - 因为没有输出。

我加快了对日志的调试并得到了:

[DEBUG] 2014-08-11 15:49:55,852 com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@7a754707], property=struts]
[DEBUG] 2014-08-11 15:49:55,853 com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@7a754707], property=struts]
[DEBUG] 2014-08-11 15:49:55,853 com.opensymphony.xwork2.DefaultActionProxy - Creating an DefaultActionProxy for namespace [/] and action name [startSubmission]
[DEBUG] 2014-08-11 15:49:55,853 com.opensymphony.xwork2.interceptor.I18nInterceptor - intercept '//startSubmission' {
[DEBUG] 2014-08-11 15:49:55,853 com.opensymphony.xwork2.interceptor.I18nInterceptor - applied invocation context locale=en_GB
[DEBUG] 2014-08-11 15:49:55,853 com.opensymphony.xwork2.interceptor.I18nInterceptor - before Locale=en_GB
[DEBUG] 2014-08-11 15:49:55,854 com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[rang.ui.actions.submission.StartSubmissionAction@35d2bd5f, com.opensymphony.xwork2.DefaultTextProvider@7a754707], property=struts]
[DEBUG] 2014-08-11 15:49:55,871 org.apache.struts2.interceptor.FileUploadInterceptor - Bypassing //startSubmission
[DEBUG] 2014-08-11 15:49:55,871 com.opensymphony.xwork2.interceptor.StaticParametersInterceptor - Setting static parameters {}
[DEBUG] 2014-08-11 15:49:55,871 com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting params NONE
[DEBUG] 2014-08-11 15:49:55,871 com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting params serviceUserNumber => [ 123456 ] submissionType => [ LIVE ] 
[DEBUG] 2014-08-11 15:49:55,871 com.opensymphony.xwork2.conversion.impl.XWorkConverter - Retrieving convert for class [class rang.ui.actions.submission.StartSubmissionAction] and property [serviceUserNumber]
[DEBUG] 2014-08-11 15:49:55,995 com.opensymphony.xwork2.conversion.impl.XWorkConverter - Converter is null for property [serviceUserNumber]. Mapping size [0]:
[DEBUG] 2014-08-11 15:49:55,995 com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type converter for property [serviceUserNumber] = none found
[DEBUG] 2014-08-11 15:49:55,995 com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level type converter for property [serviceUserNumber] = none found
[DEBUG] 2014-08-11 15:49:55,995 com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@44158e17]
[DEBUG] 2014-08-11 15:49:55,995 com.opensymphony.xwork2.conversion.impl.XWorkConverter - Retrieving convert for class [class rang.ui.actions.submission.StartSubmissionAction] and property [submissionType]
[DEBUG] 2014-08-11 15:49:55,996 com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type converter for property [submissionType] = none found
[DEBUG] 2014-08-11 15:49:55,996 com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level type converter for property [submissionType] = none found
[DEBUG] 2014-08-11 15:49:55,996 com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@44158e17]
[DEBUG] 2014-08-11 15:49:55,996 org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor - Validating //startSubmission with method execute.
[DEBUG] 2014-08-11 15:49:56,251 com.opensymphony.xwork2.validator.ValidationInterceptor - Invoking validate() on action rang.ui.actions.submission.StartSubmissionAction@35d2bd5f
[DEBUG] 2014-08-11 15:49:56,251 com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot find method [validateExecute] in action [rang.ui.actions.submission.StartSubmissionAction@35d2bd5f]
[DEBUG] 2014-08-11 15:49:56,251 com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot find method [validateDoExecute] in action [rang.ui.actions.submission.StartSubmissionAction@35d2bd5f]
[DEBUG] 2014-08-11 15:49:56,252 com.opensymphony.xwork2.DefaultActionInvocation - Executing action method = null
[DEBUG] 2014-08-11 15:49:56,342 org.apache.struts2.dispatcher.ServletDispatcherResult - Forwarding to location null

行动准则:

     public String execute() throws Exception {

        if (!StringUtils.isNumeric(serviceUserNumber)||serviceUserNumber.length()!=6) {
            super.addActionError("servce user number must be 6 numeric characters only!");
            return ERROR;
        }

        logger.debug("submission object created for SUN: " + this.serviceUserNumber + " submission type: " + this.submissionType);

        return SUCCESS;
    }

Spring config:

<bean id="startSubmissionAction" class="rang.ui.actions.submission.StartSubmissionAction">
</bean>

上传文件操作:

<action name="uploadFile" class="uploadFileAction">
    <result>/jsp/main/bip/uploadFile.jsp</result>
    <result name="error">/jsp/main/bip/submssionError.jsp</result>
</action>

此项目中的其他操作正常。该操作是Spring映射的,一切正常。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

破解

操作中会抛出异常。

真正的罪魁祸首是我定义了一个异常处理程序并且它被破坏了。