mercredi 4 mars 2015

I am working on a spring mvc application. I needed an async request, so I came across a request which returns Callable


TestController.java



@RequestMapping(value ="/views/async", method = RequestMethod.GET)
public Callable<String> getViewAsyncWay(){
return new Callable<String>(){
Thread.sleep(5000);
return "test-async"
};
}


test-async.jsp



<div>This page is delivered with async request.</div>


home.jsp



$(document).ready(function(){
$('btn-aync-req').on('click', function(){
$.ajax({
type: 'GET',
url: "<c:url value="/views/async"/>",
success: function(data){
$('#container').html(data);
}
});
});
});

<body>
<div id="container">
</div>
<input type="button" id="btn-async-req" value="Send Request"/>
</body>


Now when I click on the Send Request, server log says request processed normally and the resource returned is /views/aysnc.jsp (which is my request uri)


I am not able to figure out which step I am making mistake.


To applicationContext.xml I have added:



<task:annotation-driven/>


The normal spring-mvc request in my project works fine.


Aucun commentaire:

Enregistrer un commentaire