vendredi 27 novembre 2015

How to make pjax work in java web application?

I am trying to make pjax work at my existing java applications. And I am testing on the basic uses but I can't find any useful resources or example for java application.

As github page says:

Magic! Almost. You still need to configure your server to look for pjax requests and send back pjax-specific content.

The pjax ajax request sends an X-PJAX header so in this example (and in most cases) we want to return just the content of the page without any layout for any requests with that header.

The example at github page is for rails :

def index
  if request.headers['X-PJAX']
    render :layout => false
  end
end

Does this do the same thing like @ResponseBody of Spring MVC?

I have configured a filter and use:

System.out.println("pjax---------------->" + (httpServerRequest.getHeader("X-PJAX")));

and find that this header is true so the pjax requests did send to the server,but how can I set the right response with java in order to make pjax work correctly?




Aucun commentaire:

Enregistrer un commentaire