Ajax SPRINGMVC Controller report 404 error and form submission

Source: Internet
Author: User

Today encountered a very strange problem, the front desk Ajax write URL address clearly and controller requestmapping address match, but has been reported 404 error. Later, compared with other methods, it was found that there was no annotated @responsebody. Plus, it's normal after that.

@ResponseBody annotation means direct output, so I always thought that only with the output content, always think it should be the first match the address, and then match the right, the execution method again output content, it seems not so.

Also note the two ways to submit a foreground table:

$.ajax ({                URL: "Your_url",                data:$ ("#Form"). Serialize (),                type: "Post",                success: function(data) {                    if (data.code== "0") alert ("Success"), Else alert ("Failure"   

The data in the table is serialized, the data type is not specified as JSON, the corresponding method can not be added @requestbody when the parameters are accepted;

② the second method is relative to the first method, the data in the table is converted to JSON, the data format is also specified as JSON, the corresponding method must be added @requestbody annotations when receiving parameters;

Obviously the first one is simpler. Both methods will report 503 (incorrect data format) if there is no good docking.

Ajax SPRINGMVC Controller report 404 error and form submission

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.