How we can get person information on spring mvc & mongodb

I am trying to get one person record on mongodb with spring mvc using ajax call.

this is ajax code in index.jsp:

    $(document).on("click","a.edit",function(){
        var id=this.id;

        $.ajax({
            url:"edit.htm",
            data:{id:id},
            success:function(response){
                alert(response); 
            }
        });
    });

This is PersonService Class get method:

public Person getPerson(String id) {
    return mongoOperations.findOne( Query.query(Criteria.where("_id").is(id)),
                                Person.class,
                                COLLECTION_NAME) ;
} 

This is ajaxEditPerson method in PersonController Class:

@RequestMapping(value = "/edit", method = RequestMethod.GET)
public @ResponseBody String ajaxEditPerson(
       @ModelAttribute Person person, 
       ModelMap model,
       @RequestParam(value="id") String id) {

      model.addAttribute("personOne", personService.getPerson(id));

     return "test";
}

I want to get person infos in index.jsp using ETL:

${personOne.name}

But it doesnt send response to index.jsp.

How can I fix this?

Thanks


Source: jsp

Leave a Reply