掲示板

Encoding URL

7年前 に Madhukara Patel によって更新されました。

Encoding URL

Junior Member 投稿: 46 参加年月日: 15/03/23 最新の投稿
Hi,

I want pass some values in resource url as format of Json.
Json contains values like getValue('var1') .

While retrieving i am facing some value some escape character need to add.

How to pass value like this in resource url.

Thank you in advance...
thumbnail
7年前 に Devang Patel によって更新されました。

RE: Encoding URL

Regular Member 投稿: 247 参加年月日: 15/01/19 最新の投稿
Hi Madhukara Patel,

Create resource URL :
<portlet:resourceurl var="resourceURL">
</portlet:resourceurl>


Write Ajax to send data in JSON :
$.ajax({
  url : '${resourceURL}',
  data : data,//hospital id to sent
  type: 'POST',
  dataType : "json",
  success : function(data) {
    // get hospital data back from controller
  }
});


Now retrieve data in ServeResource Method :

public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

    //get hospital id using getparameter 

    JSONObject json = JSONFactoryUtil.createJSONObject();

    json.put("jsonData", "hospital details");
    response.getWriter().write(json.toString());

}


HTH.

Regards,
Devang Patel