weixin_33716154 2012-05-28 02:54 采纳率: 0%
浏览 22

从控制器获取参数

i'm planning to do this. when user click course name in the first page, it will go to the second page with the parameter. i've pass the parameter from first page to the controller. but i don't know how to get from the controller? should i use like this? if i use hard coded as below,

var idInput = "123";
var regNoInput = "123";

it will display in the console but not in the display but its okay for the first step.. but when i did like below, it will display null in the console.. please help me.. i'm really need help here.

$('#MregisteredClassesDetails').live('pageshow', function(){
    var rowInput = "1";
    var pageInput = "1";
    var idInput = document.getElementById("courseId");//value take from controller
    var regNoInput = document.getElementById("regNo");//value take from controller

    $.ajax({
     url: '${pageContext.request.contextPath}/getRegisteredClassesDetails.html',
     data: ( {rows : rowInput, page : pageInput, courseId : idInput, regNo : regNoInput}),
     type: 'POST',

     success: function(json_results){
       $('#list').append('<ul data-role="listview" data-inset="true"</ul>');
       listItems = $('#list').find('ul');
       html  = '#################################################################################################';
       html += '<h1>' +json_results.courseName+'</h1>';
       html += '#################################################################################################';
       html += '<br> Registration #    : '+json_results.regNo+'</br>';
       html += '<br> Status            : '+json_results.regStatus+'</br>';
       html += '<br> Location          : '+json_results.courseLoc+'</br>';
       html += '<br> Start Date        : '+json_results.startDate+'</br>';
       html += '<br> Registered Person : '+json_results.fullName+'</br>';
       html += '<br> Rate              : '+json_results.rate+'</br>';
       listItems.append(html);

       $('#list ul').listview();
       $.mobile.pageLoading(true);      
    }
});
});

but when i debug in my controller, in the console, both of the parameter is null

2012-05-28 10:35:57,085 DEBUG [http-bio-137.57.102.146-8080-exec-6] TrainingController -   courseId:null
2012-05-28 10:35:57,085 DEBUG [http-bio-137.57.102.146-8080-exec-6] TrainingController - registerNo:null

what should i do? i can;t display data if the i fail to retrieve the parameter

  • 写回答

1条回答 默认 最新

  • 普通网友 2012-05-28 03:05
    关注

    try like this

    $.ajax({
     url: '${pageContext.request.contextPath}/getRegisteredClassesDetails.html',
     data:"{'rows ': '" + rowInput + "', 'page ': '"+ pageInput +"', 'courseId' : '"+ idInput+"', 'regNo' : '"+ regNoInput + "'}",
     type: 'POST',
     contentType: "application/json; charset=utf-8",  
      dataType: "json", 
     success: function(json_results){
    ......
    

    });

    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退