Java Web Learning Note (1)

Source: Internet
Author: User

1. The project name is in lowercase, the class name is camel-like, the object name is camel-style but the first letter is lower case;

2. Write the object property when the blank line, the first method is also blank line, generally to add comments;

3.new new object when the equal sign around the space, if the statement is left and right to shake a space;

4.crl+shift+o the introduction of other package, or other classes; 5./+**+enter key for the appearance of comments;

6. Job: Why is equal to string with equals and use equals number is direct with = =; Solution: Java is an object with no operator string.         is not a simple type, only a simple type can use = =. If you want to use = =, you need to implement Hashcode method;

The 7.sysout+enter key can appear System.out.println ("");

8. For the Get and set methods, you can directly right-click on the variable that needs to generate the method, this can occur source-generate getters and setters can be automatically generated method;

9. Create a Spring Project:   (1) generate three package in SRC directory, import data for Com.zlz.dao, Com.zlz.service Create the service, Com.zlz.test is the main class inside, can be used for testing;   (2) Create a new folder, named Resources, and pour the spring file in XML format to configure ~ ~ ~       The role of spring is to rely on control and injection inversion;       in spring       <bean id= "Userdao" class= " Com.zlz.dao.UserDao "></bean>        key (ID) Inside the package Com.zlz.dao inside the class Userdao inside the Userdao method, class inside the structure is the package name. class name;

      <bean id= "UserService" class= "Com.zlz.service.UserService" >        <property name= "Userdao" ref= "Userdao" ></property>       </bean>       In order to show the package Com.zlz.service refers to the package Com.zlz.dao inside the method, the property inside the name is package Com.zlz.service inside also contains Userdao method,        the method used for ref is to refer to the Userdao method in the class Userdao inside the package Com.zlz.dao       the way it behaves is a dependency, Can save space, in the UserService method can not be a new object but directly call the method in another class, by loading       code below        Classpathxmlapplicationcontext application = new Classpathxmlapplicationcontext ("Applicationcontext.xml");       userservice Userservicebean = (userservice) application.getbean ("UserService");       userservicebean.insertuser ("admin");   (3) Create another new folder, the name Lib, copy inside the package Commons-logging.jar and Spring.jar, and then select both packages right-click BuildPath;

Java Web Learning Note (1)

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.