Popular explanations of annotations in spring

Source: Internet
Author: User
We defined the DAO layer bean in the spring configuration file when we did not write the spring configuration file with annotations.
So we write the Setdao method in the service layer, we can call the DAO layer directly through the interface,
After using the annotation notation, the DAO layer bean is not written in the configuration file.
Only need to include in the DAO implementation class
@Repository
Public Class Testdaoimpl () {}



Private Testdao Testdao;


Join at service level
@service
Public Class Testservice () {}
Write directly in this action
@Autowired
Private Testservice Testservice;


In the action layer join
@Controller
Public Class testaction () {}
You do not need to define an action bean in the configuration file

@requestMapping is the spring-mvc thing,
Before we used struts2, we needed a configuration file to define the name of the action,
To write xxx.do in the browser to access the action method

After using SRPING-MVC, in the action method, add the
@controller
public class Testaction () {
@requestMapping ("Xxx.do")
Public String FindAll () {
.................
}
}
In this way, you do not need struts, directly in the browser input xxx.do can access the FindAll method

Popular explanations of annotations in spring

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.