Java - Spring - portlet API @Controller how to read ajax parameters -


i have following latest jquery v aajx call multiple parameters.

in java code able first parameter value rest of them found null.

$.ajax({         url : '<portlet:resourceurl id="entitledrequest"/>',         data: '<c:out value="pfx= ${account.accountnumber}-${outletui.outlet}-${count}&acc=${account.accountnumber}" />',         cache: false,         success : function(result) {              //targetelem.html(result); update ui          }     }); 

following java code first parameter not null after params null, have debug http request parameters present in request object clue whats wrong here ?

controller("ajaxrequestcontroller") @requestmapping(value = "view") public class ajaxrequestcontroller implements portletconfigaware  {   @resourcemapping("entitledrequest")     public void getserviceautocomplete(resourcerequest request, resourceresponse response) throws ioexception {               string elemprefix = request.getparameter("pfx");             string acc = request.getparameter("acc"); // found null             string mac = request.getparameter("mac"); // found null  }... 

use @requestparam annotation read parameters.

@resourcemapping("entitledrequest") public void getserviceautocomplete(@requestparam("pfx")  string elemprefix, @requestparam  string acc, @requestparam string mac, resourcerequest request, resourceresponse response) throws ioexception {  } 

reason:

the parameters sent ajax doesn't fall in portletnamespace. hence, not part of resourcerequest can found in normal httpservletrequest. spring searches @requestparam names in httpservletrequest.

you can either use approach suggested me -or- can add <portlet:namespace/> parameters in ajax call keeping controller code intact.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -