Struts2 不执行 setter 偶尔

Struts2 not performing setter occasionally

我使用 Struts2+JSP+Waffle 作为我的 Java EE 框架。 在其中一个 JSP 中,我制作了一个带有 post 操作的表单,将数据作为对象传输,类似于:

<input type="text" name="bookVo.isbn_no" id="isbn_no">

...程序将设置一个新的 "bookVo",其中包含大量输入值。我的程序将执行函数 save() 以获取 bookVo 并执行一些 SQL 操作。

我在我的函数中添加了一些日志,这是我目前得到的:

  1. 程序正常执行,它会先setBookVo()然后save().
  2. 我使用 Waffle 为 windows 用户进行一键登录,它根据登录的 windows 用户检测用户详细信息,并在不输入密码的情况下执行快速登录。
  3. 问题发生在之后 我实现了 Waffle,记录器显示它跳过了 bookVo() 但执行了 save (),最终导致我在 bookVo.
  4. 中的值出现 Nullpointerexception

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
    <constant name="struts.custom.i18n.resources"
        value="com.booksys.resources.property.message.CommonResources" />

    <constant name="struts.multipart.maxSize" value="52428800" />
    <constant name="struts.devMode" value="false" />

    <constant name="struts.ognl.allowStaticMethodAccess" value="true" />

    <constant name="struts.enable.DynamicMethodInvocation" value="true" />

    <package name="default" extends="struts-default">
        <result-types>
            <result-type name="layout1" class="com.booksys.common.MyTilesTemplateResult" />
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>

        <global-results>
            <result name="exception">/jsp/common/exception.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception"
                result="exception"></exception-mapping>
        </global-exception-mappings>

        <action name="login">
            <result>/login.jsp</result>
        </action>

    <package name="ajax" extends="json-default">
        <interceptors>
            <interceptor-stack name="defaultStack">
                <interceptor-ref name="json">
                    <param name="enableSMD">true</param>
                </interceptor-ref>
                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>
        </interceptors>

        <action name="*JsonAction" method="{1}" class="com.booksys.ajax.JsonAction">
            <result name="fail"></result>
            <result type="json">
                <param name="root">result</param>
            </result>
        </action>
    </package>
</struts>

bookSave.jsp:

<s:form action="booksave.action" method="post" name="form1" id="form1">
 ...more inputs...
 <button id="saveBtn" type="button" onclick="save();">Save</button>
</s:form>

function save() {
            if(!checkForm()) {
                /*check each input value, if any input is null or "", return false*/
                return false;
            }

            $( "input:disabled" ).attr("disabled", false);

            $('#form1').attr('action','booksave.action');
                $("#form1").submit();
        }

由于这个问题偶尔会发生,我真的不知道从哪里开始寻找解决方案,知道这是怎么发生的吗?

经过几天的监控,一些更改似乎奏效了,以下是我所做的更改:

  1. 删除 struts.xml
  2. 中的拦截器
  3. 将 Waffle 分离到另一个目录,然后 link 它到登录页面

注意:在我 post 编辑这个 post 之后,我已经完全删除了 Waffle,但是在完全重启之后,服务器似乎具有相同的发生错误,所以我仍然不确定是什么导致了这个错误以及如何解决这个问题。不知何故几天后,问题自行消失了...