AJax技术

News: Ajax and JQuery autocomplete integration with Spring M

字号+ 作者:H5之家 来源:H5之家 2017-11-17 18:00 我要评论( )

News: Ajax and JQuery autocomplete integration with Spring MVC ,ITPUB论坛-中国最专业的IT技术社区

I believe after Spring blog announced Ajax integration with Spring MVC, many of us are excited.

The best part is add @ResponseBody in your controller and Spring will create JSON response for you.

@RequestMapping(value=”/testJquery”, method=RequestMethod.GET)
public @ResponseBody List getProperResponse(@RequestParam String name) {

}

jquery autocomplete
() expects json response in the following format.

{
label: blablabla

value: blablabla

}

So your ResponseBean should have following annotations and field names

ResponseBean{

@JsonProperty(value=”label”)
String name;

@JsonProperty(value=”name”)
String value;
}

You need entry in your dispatcher-servlet.xml so that Jackson Jars are invoked to formulate your ajax response.

And you need jackson jars in app server classpath.
(jackson-core-asl-1.9.5 and jackson-mapper-asl-1.9.5)

Install firbug to see your json response. If its improper, it means that jackson jars are not being picked up by your Spring and you may need to place them in your classpath.

Thats all for now. Happy coding with Spring



Ajax, JQuery, integration, Spring, font

 

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

相关文章
  • Resume Manager 简历管理器,去掉 ajax.googleapis.com 加速。

    Resume Manager 简历管理器,去掉 ajax.googleapis.com 加速。

    2017-11-17 17:05

  • Ajax的优缺点都有哪些?

    Ajax的优缺点都有哪些?

    2017-11-17 10:01

  • Ajax Blog 用到的几个函数第1/3页

    Ajax Blog 用到的几个函数第1/3页

    2017-11-17 10:00

  • ajax学习札记(三)

    ajax学习札记(三)

    2017-11-16 12:02

网友点评