Spring constructor injection method and initial Ajax access

Source: Internet
Author: User

Another injection method of spring is to inject through the JavaBean constructor. It differs from setting value injection in that constructor-Arg must be used as the tag in the configuration file, while setting value injection uses the property. In addition, you need to add the parameter constructor In the caller's implementation class. The called user is used as the construction parameter.

Advantages and disadvantages:

To be supplemented ......

Construction injection may affect performance. Therefore, constructor injection is not applicable to recommendations with complex dependencies. Constructor injection is recommended for fixed dependencies. Value-based injection, supplemented by construction injection.

Ajax today understands prototype when a component is used. When will Ajax be used? 1. If you do not want the information you entered to exit your implementation, you may need to fill in all the information you entered after the original submission, resulting in inconvenience in use. 2. You only need to submit some content, for example, many parts of the entire page, including a login window. You only need to submit the login information. If all the information is submitted, the page will be rerefreshed, affecting the speed.

It is worth noting that AJAX depends on the operating system encoding. The operating system in China is generally gb2312. Therefore, remember to transcode the submitted content,

Use for receiving:

String name = new string (request. getparameter ("name"). getbytes ("ISO-8859-1"), "gb2312 ");

Use the following command to return data:

Response. setcharacterencoding ("gb2312 ");
Response. getoutputstream (). println (result );

Response. flushbuffer ();

To prevent Chinese garbled characters.

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.