Creating a json object in jsp and using it with JQuery

后端 未结 4 1545
既然无缘
既然无缘 2020-12-01 22:54

I\'ve created a JSP application, which gets results based on a user search (using lucene). I store the results in a Bean.

I\'m also using Jquery Ajax to display the

4条回答
  •  北海茫月
    2020-12-01 23:25

    Ultimately its being trasnferred over http. So, creating a json object wont do much help.

    I am not a java expert but you can create a simple string which matches with json structure and then parse it on client side.

    Like

    string s =  { "title": "testTitle", "link" : "testLink"}
    out.println(s)
    

    This will do the trick.

    Edit: by seeing Darin's answer,

    Include this on you java code,

    <%@page contentType="application/json; charset=UTF-8"%>
    

提交回复
热议问题