【问题标题】:Grails - Send List of objects in params of redirectGrails - 在重定向参数中发送对象列表
【发布时间】:2016-06-16 05:55:56
【问题描述】:

我的问题是我想在索引视图上预览数据而不将数据保存在数据库中。为此,我想在重定向的参数部分发送对象列表。并且在接收操作时想要使用该对象列表。但是当我包含如下内容时

def preview(){
//some code
redirect action: "index", params:[planId:params.planId, beamsInfoList: beamsInfoList]
}

我希望发生类似下面的事情。

def index() { 
    //some code
    try{

        planInfo.beamInfo = (params.beamsInfoList==null)?planInfo.beamInfo:params.beamsInfoList //beamInfo is also list

        //some code

    Object[] obj = GRMUtils.calculateTotalBeamsPower(planInfo.beamInfo)
    totalPlanPower = (Float)obj[0];
    beamPowerMap= (Map<Integer, String>)obj[1];
    AmMapUtility utility=new AmMapUtility()
    output = utility.generateAMmapFromBeams(planInfo.beamInfo, GRMConstants.POWER_MAP_PAGE);
    if(null==output){
        flash.error = message(code: 'beammap.noinfoerror.message')
    }
    }catch(Exception e){
    log.error "Excepton occured while loading Power Map", e
}
    respond beams, model:[centerLong:output.getCenterLongitude(),centerLat:output.getCenterLatitude(),amMapImageProperty:output.getMapImages(),
        amMapLinesProperty:output.getMapLines(), planId:params.planId, planInfo:planInfo, powersControlCarrier: powersControlCarrier, powersTrafficCarrier:powersTrafficCarrier,satPower: planInfo.satellite.satelliteMaxPower, totalPlanPower: totalPlanPower, gatewayPower: planInfo.gateway.gatewayAggregateEIRP,fesOutputPowerLimit:fesOutputPowerLimit, beamPowerMap: beamPowerMap,powerRangeColorMap:output.getReuseColorMap()]

}

它不会重定向到 index 方法,也不会显示任何错误。两个动作都在同一个控制器中。我使用过闪存,但作为第二个请求所反映的价值,它也无济于事。我也尝试过会话,但出现错误

org.hibernate.LazyInitializationException: could not initialize proxy - no Session

在一些数据库提取上。我被困住了。我是 grails 和 groovy 的新手。请帮忙。

编辑:我发现我的列表很大,这就是它不重定向的原因。请帮助我另一种选择,例如如果可能的话,我该如何使用请求属性?

【问题讨论】:

    标签: grails groovy


    【解决方案1】:

    我想我已经解决了这个问题。它现在工作。我需要做的就是使用请求 setattribute as

    request.beams = beams
    

    并且不需要在重定向的参数中传递列表,这是我之前习惯做的。我没有使用重定向,而是使用如下转发:

    request.beams = beams
    
    forward action: "index", params:[planId:params.planId]
    

    【讨论】:

      猜你喜欢
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 2011-11-05
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多