【问题标题】:Getting data from one jsp to another从一个jsp获取数据到另一个
【发布时间】:2016-01-19 09:14:09
【问题描述】:
Map<String, String> vignetteContent2 = buildVignetteContent2(
            actionState, "reenrolmentSummary");

    actionState.request.setAttribute("memberName", member.getFirstName());
    actionState.request.setAttribute("confirmNum", PayrollDedutionTransactionHelper.getConfirmationNumber());
    actionState.request.setAttribute("effectiveDate", getDisplayDateInMMMMDYYYY(PayrollDedutionTransactionHelper.getTransactionEffectiveDate(), actionState.getLanguageCode()));
    actionState.request.setAttribute("reenrolWelcome", reenrolmentSesssionData.getPayrollDeductionPageData());
    actionState.request.setAttribute("assetConsolidationAllowed",actionState.appSecurityManager.isAssetConsolidationAllowed(actionState.session));
    actionState.request.setAttribute("vignetteContent2", vignetteContent2);

    pageData.put("hubToolName", hubToolName);
    actionState.jspPageData = pageData;

    return true;

我想在其他一些jsp中获取属性confirmNum和effectiveDate。 我试过这个,但我知道这是不正确的。还请说明我们是如何制作这张地图的以及我们是如何获取数据的。

function setDateAndConfirmation(paymentMethod){
            var date = new Date($.now());
//          var dateString = $.datepicker.formatDate('dd M yy', date);
            var hours = date.getHours();
            if(hours < 10){
                hours = "0" + hours;
            }
            var minutes = date.getMinutes();
            if(minutes < 10){
                minutes = "0"+minutes;
            }
            var seconds = date.getSeconds();
            if(seconds < 10){
                seconds = "0" + seconds;
            }
            $("#dateSubmitted").effectiveDate;


            $("#confNumber").confirmNum;
        }

        setDateAndConfirmation("P");

【问题讨论】:

  • 什么....."请解释一下我们是如何制作这张地图的以及我们是如何获取数据的" ??哈哈。要获取数据,要么映射到类,要么使用存储数据的设计模式(例如服务层),然后再发送并从其他方法调用它。
  • 伙计,几周前我刚刚开始研究 Java。所以如果你觉得这很有趣,那么我道歉。
  • 我明白了。只是你提到的方式很有趣。您知道如何存储数据,或将数据映射到类并检索它吗?这可能会有所帮助。
  • 是的,我知道我们使用 put 方法为键分配特定值。我们可以使用迭代器来检索它。这只是我知道的基本知识。

标签: java jsp dictionary attributes


【解决方案1】:

你也可以在你的控制器中使用这样的东西:

@ModelAttribute("confirmNum")
protected String confirmNum(HttpSession session){

       return PayrollDedutionTransactionHelper.getConfirmationNumber();

    }

然后在您的其他 JSP(视图)中调用该属性,就像您的初始 JSP 和其他视图一样。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多