JSON

springmvc学习笔记(18)-json数据交互(2)

字号+ 作者:H5之家 来源:H5之家 2016-03-15 11:00 我要评论( )

显示两个按钮分别测试 jsp页面 span class=vbscript%-- Created by IntelliJ IDEA. User: brian span class=hljs-built_inDate/span: span class=hljs-number2016/span/span class=hljs-number3/span/span class=hl

显示两个按钮分别测试

  • jsp页面
  • <span class="vbscript"><%-- Created by IntelliJ IDEA. User: brian <span class="hljs-built_in">Date</span>: <span class="hljs-number">2016</span>/<span class="hljs-number">3</span>/<span class="hljs-number">7</span> <span class="hljs-built_in">Time</span>: <span class="hljs-number">20</span>:<span class="hljs-number">49</span> <span class="hljs-keyword">To</span> change this template use File | Settings | File Templates. --%></span> <span class="vbscript"><%@ page contentType=<span class="hljs-string">"text/html;charset=UTF-8"</span> language=<span class="hljs-string">"java"</span> %></span> <span class="hljs-tag"><<span class="hljs-title">html</span>></span> <span class="hljs-tag"><<span class="hljs-title">head</span>></span> <span class="hljs-tag"><<span class="hljs-title">meta</span> <span class="hljs-attribute">http-equiv</span>=<span class="hljs-value">"Content-Type"</span> <span class="hljs-attribute">content</span>=<span class="hljs-value">"text/html; charset=UTF-8"</span>></span> <span class="hljs-tag"><<span class="hljs-title">title</span>></span>json交互测试<span class="hljs-tag"></<span class="hljs-title">title</span>></span> <span class="hljs-tag"><<span class="hljs-title">script</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"text/javascript"</span> <span class="hljs-attribute">src</span>=<span class="hljs-value">"${pageContext.request.contextPath }/js/jquery-1.4.4.min.js"</span>></span><span class="javascript"></span><span class="hljs-tag"></<span class="hljs-title">script</span>></span> <span class="hljs-tag"><<span class="hljs-title">script</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"text/javascript"</span>></span><span class="javascript"> <span class="hljs-comment">//请求json,输出是json</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">requestJson</span><span class="hljs-params">()</span>{</span> 省略 } <span class="hljs-comment">//请求key/value,输出是json</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">responseJson</span><span class="hljs-params">()</span>{</span> 省略 } </span><span class="hljs-tag"></<span class="hljs-title">script</span>></span> <span class="hljs-tag"></<span class="hljs-title">head</span>></span> <span class="hljs-tag"><<span class="hljs-title">body</span>></span> <span class="hljs-tag"><<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"button"</span> <span class="hljs-attribute">onclick</span>=<span class="hljs-value">"requestJson()"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"请求json,输出是json"</span>/></span> <span class="hljs-tag"><<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"button"</span> <span class="hljs-attribute">onclick</span>=<span class="hljs-value">"responseJson()"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"请求key/value,输出是json"</span>/></span> <span class="hljs-tag"></<span class="hljs-title">body</span>></span>
  • controller
  • <span class="hljs-annotation">@Controller</span> <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">JsonTest</span> {</span> 省略 }
  • 测试结果
  • 输入json串,输出是json串

     

    1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

    相关文章
    • JSON复杂数据处理之Json树形结构数据转Java对象并存储到数据库的

      JSON复杂数据处理之Json树形结构数据转Java对象并存储到数据库的

      2016-03-15 10:14

    • Python解析json文件相关知识学习

      Python解析json文件相关知识学习

      2016-03-14 17:00

    • Spring MVC 学习笔记11

      Spring MVC 学习笔记11

      2016-03-07 16:01

    • IOS学习笔记(16)网络请求,json解析

      IOS学习笔记(16)网络请求,json解析

      2016-03-01 17:00

    网友点评
    "