HTML5如何和JAVA后台数据交互?

Python048

HTML5如何和JAVA后台数据交互?,第1张

java

web,,或者叫jsp。jsp就是由html和java脚本,等语言构成的。

java程序嵌套在html里。相当于php。以网页的形式将java展现。这也就是所谓的动态。

以为java程序获取的时间会变动。或者数据库变动从而引起网页的变动。

具体实现,你可以在网上查找jsp教程。

javascript

        var param = "url=" + $("#url").val()

            $.ajax({

                  type: "POST",

                  url: "targetAction!targetMethod.action",

                  data: param,

                  dataType: "json",

                  success: function(json){

                     alert(json)

                  },

                  error:function(){

                      alert("连接超时")

                  }

            })

java

        ServletResponse response = ServletActionContext.getResponse()

        response.resetBuffer()

        response.setCharacterEncoding("utf-8")

        response.getWriter().print(JSONArray.fromObject(data))

js端需要有个jquery,java端需要有个json-lib,这两个你可以到网上下载