English 中文(简体)
从控制器获取参数
原标题:get parameter from controller

i m 计划这样做。 当用户在第一页单击课程名称时, 它会用参数转到第二页。 我将参数从第一页传给控制器。 但我不知道如何从控制器获取参数? 我是否应该这样使用? 如果我使用以下硬编码,

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

它会显示在控制台中, 但不显示在显示中, 但第一步还可以。 但是当我像下面一样, 它会在控制台中显示空。 请帮助我. im在这里真的需要帮助 。

$( #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);      
    }
});
});

但当我在我的控制器中调试时, 在控制台中, 两个参数都是空的

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

如果无法检索参数, 我应该做什么? I can; 如果无法获取参数, 我将无法显示数据 。

问题回答

像这样试试

$.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){
......

});





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签