Controller Considerations in Spring Boot

Source: Internet
Author: User

Spring boot controller The depth of the water, after learning, I summarize some tips for later reference, reduce errors:

1.controller There are two main tags: @Controller and @restcontroller, two labels can not function at the same time, the former labeled class can only return static files, the latter labeled class for returning data types such as JSON string

2. When using the @controller tag, the file under the templates is not recognized (it has been tested, found and many other online statements are not the same), only the static folder under the file can be read directly, the specific code is as follows:

@RequestMapping (value= "/", method= requestmethod.get) public
String Home () {
    return "views/index.html";
}
Here static is accessed as the root directory.

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.