如果结果类型为json,则调用两次Struts2操作

如果结果类型为json,则调用两次Struts2操作,json,struts2,struts2-config-browser,Json,Struts2,Struts2 Config Browser,我有一个包含4种动作方法的动作类。 所有四种操作方法都使用json结果 通过日志语句和调试,我验证了如果调用操作方法1,也会调用操作方法2和3。但不是4。最后,再次调用action方法1并生成json结果 如果我将Action method 1的结果类型更改为带有jsp位置的默认dispatcher,则只调用Action method 1。(这是我想要的json结果的行为) 希望这是有道理的 有人有什么想法吗? 这个问题是在这里提出的 但是没有人回答。 如果你需要更多信息,请告诉我 @Resul

我有一个包含4种动作方法的动作类。 所有四种操作方法都使用json结果

通过日志语句和调试,我验证了如果调用操作方法1,也会调用操作方法2和3。但不是4。最后,再次调用action方法1并生成json结果

如果我将Action method 1的结果类型更改为带有jsp位置的默认dispatcher,则只调用Action method 1。(这是我想要的json结果的行为) 希望这是有道理的

有人有什么想法吗? 这个问题是在这里提出的

但是没有人回答。 如果你需要更多信息,请告诉我

@ResultPath("/WEB-INF/jsp/dta/")
public class GroupEntityAction extends BaseAction {
    /**
     * 
     */
    private static final long serialVersionUID = 6750675222824235086L;
    private static Logger log = Logger.getLogger(GroupEntityAction.class);

    private List<EntityBusiness> theUnusedEntityBusinessList;
    private String assignedEntities[];
    private long groupId;
    private long businessId;
    private String parentMe;
    private long rptYear;
    private String ssoId;
    private String isSubmitted;

    private String delimGoLiveEmails;
    private List<String> theEmailList;

    @Action(value = "ajaxGetAvailableEntityList",
            results = { @Result(name = "success", type = "json") }
            ,
            interceptorRefs = { @InterceptorRef("dtaStack"),
                    @InterceptorRef(value = "dtaStack", params = { "appInterceptor.allowedRoles", "ADMIN" }) }
            )
            public String getEntityListsByBusiness() throws Exception {

        if (rptYear == 0) {
            return SUCCESS;
        }

        LookupService theSvc = new LookupService();

        if (businessId != 0) {
            setTheUnusedEntityBusinessList(theSvc.getAvailableEntityListBizExceptIds(rptYear, businessId, ssoId, assignedEntities));
        } else {
            setTheUnusedEntityBusinessList(theSvc.getAvailableEntityListParentMeExceptIds(rptYear, parentMe, ssoId, assignedEntities));

        }

        log.debug(theUnusedEntityBusinessList.size());

        return SUCCESS;
    }

    @Action(value = "ajaxToggleGroupBusinessSubmitted",
            results = { @Result(name = "success", type = "json") }
            ,
            interceptorRefs = { @InterceptorRef("dtaStack") }
            )
            public String toggleGroupBusinessReview() {

        try {
            new ProformaService().toggleIsSubmitted(getCurrentUser().getSsoId(), groupId, rptYear, businessId);
        } catch (SQLException e) {
            log.error(e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }

    @Action(value = "ajaxGetGoLiveEmailList",
            results = { @Result(type = "json") }
            ,
            interceptorRefs = { @InterceptorRef("dtaStack"),
                    @InterceptorRef(value = "dtaStack", params = { "appInterceptor.allowedRoles", "ADMIN" }) }
            )
            public String getGoLiveEmailList() {

        try {
            List<TaxUser> theUserList = new SecurityService().getAll();

            List<String> theEmailList = new ArrayList<String>();
            for (TaxUser theUser : theUserList) {

                if ((!theUser.getRoles().contains("ADMIN")) && (theUser.getIsActive().equalsIgnoreCase("Y"))) {
                    if (!theEmailList.contains(theUser.getEmail())) {
                        theEmailList.add(theUser.getEmail());
                    }
                }
            }

            setDelimGoLiveEmails(StringUtils.join(theEmailList.toArray(), "|"));
            setTheEmailList(theEmailList);
        } catch (SQLException e) {
            log.error(e.getMessage());
            return ERROR;
        }

        return SUCCESS;
    }

    @Action(value = "ajaxGetChaserEmailList",
            results = { @Result(name = "success", type = "json") }
            ,
            interceptorRefs = { @InterceptorRef("dtaStack"),
                    @InterceptorRef(value = "dtaStack", params = { "appInterceptor.allowedRoles", "ADMIN" }) }
            )
            public String getChaserEmailList() {

        try {

            List<String> theEmailList = new LookupService().getChaserEmailList();

            setDelimGoLiveEmails(StringUtils.join(theEmailList.toArray(), "|"));
            setTheEmailList(theEmailList);

        } catch (SQLException e) {
            log.error(e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }

    public void setTheUnusedEntityBusinessList(
            List<EntityBusiness> theUnusedEntityBusinessList) {
        this.theUnusedEntityBusinessList = theUnusedEntityBusinessList;
    }

    public List<EntityBusiness> getTheUnusedEntityBusinessList() {
        return theUnusedEntityBusinessList;
    }

    public void setAssignedEntities(String assignedEntities[]) {
        this.assignedEntities = assignedEntities;
    }

    public String[] getAssignedEntities() {
        return assignedEntities;
    }

    public void setGroupId(long groupId) {
        this.groupId = groupId;
    }

    public long getGroupId() {
        return groupId;
    }

    public void setBusinessId(long businessId) {
        this.businessId = businessId;
    }

    public long getBusinessId() {
        return businessId;
    }

    public void setParentMe(String parentMe) {
        this.parentMe = parentMe;
    }

    public String getParentMe() {
        return parentMe;
    }

    public void setRptYear(long rptYear) {
        this.rptYear = rptYear;
    }

    public long getRptYear() {
        return rptYear;
    }

    public void setSsoId(String ssoId) {
        this.ssoId = ssoId;
    }

    public String getSsoId() {
        return ssoId;
    }

    public void setIsSubmitted(String isSubmitted) {
        this.isSubmitted = isSubmitted;
    }

    public String getIsSubmitted() {
        return isSubmitted;
    }

    public void setDelimGoLiveEmails(String delimGoLiveEmails) {
        this.delimGoLiveEmails = delimGoLiveEmails;
    }

    public String getDelimGoLiveEmails() {
        return delimGoLiveEmails;
    }

    public void setTheEmailList(List<String> theEmailList) {
        this.theEmailList = theEmailList;
    }

    public List<String> getTheEmailList() {
        return theEmailList;
    }
}
,仅调用ajaxGetGoLiveEmailList


当我查看配置浏览器时,所有操作映射都已正确配置,指向正确的方法调用

JSON插件可能正在调用所有以“get”开头的方法,试图将它们序列化为输出。尝试将您的方法重命名为其他方法。

请发布您的操作代码或显示问题的测试用例。我也有同样的问题。将函数名更改为“loadxxx”。现在可以了。(:哇!谢谢,nmc。我也遇到了同样的奇怪问题。这个解决方案解决了它。非常感谢nmc。我还是不敢相信。这解决了问题。
results={@Result(location="something.jsp")