Spring and Ajax

Source: Internet
Author: User

1. Introduction to Ajax

Asynchronous JavaScript and XML asynchronous JavaScript and XML

Ajax is a technique used to improve the user experience, with the features of asynchronously processing and refreshing part of a page's content

Ajax technology requires both client-side JavaScript processing and server processing in the application.

When using AJAX technology, the following work is required

Write JavaScript programs to send AJAX requests

Write server processing, return processing results (common JSON format)

Write JavaScript programs, get server results, refresh some pages

2. Spring Support for Ajax

To facilitate the acceptance and processing of AJAX requests, Spring MVC provides support for JSON responses that can easily be automatically turned into JSON format strings for client-side JavaScript to return

In Springmvc, JSON-related annotations are @responsebody

3. @ResponseBody Application

@ResponseBody annotations are mainly used before the Controller component processing methods, the following methods are used:

The Jackson Development Kit was introduced, followed by Jackson-annotations-2.4.1.jar, Jackson-core-2.4.1.jar, Jackson-databind-2.4.1.jar

Define <MVC:ANNOTATION-DRIVEN/> in the spring configuration file, turn on support for @responsebody apps

Define @responsebody annotations before controller processing methods

@ResponseBody applications

1. Use @responsebody to return an instance of a single value as follows:

Spring and Ajax

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.