Distributed micro-service Cloud Architecture development Web application

Source: Internet
Author: User

For a simple example, on the basis of the QuickStart project, take a simple example to render a page through Thymeleaf.

@Controller Public classHellocontroller {@RequestMapping ("/")       PublicString Index (Modelmap map) {//add an attribute that is used to read from the templateMap.addattribute ("Host","http://blog.didispace.com"); //the name of the return template file, corresponding to the src/main/resources/templates/index.html        return "Index"; }    }  
<! DOCTYPE html>  "en">      <meta charset=  "UTF-8" />      <title></title>  "${host}">hello world

As on the page, directly open the HTML page to show Hello World, but after launching the program, the access http://localhost:8080/ is to display the controller in the value of host: http://blog.didispace.com , do not break the HTML itself content of the logical separation of data.

If you need to modify the default configuration, just copy the following to modify the properties into the application.properties , and modify the required values, such as modifying the template file extension, modify the default template path, and so on.

# Enable Template caching. Spring.thymeleaf.cache=true# Check The templates location exists. Spring.thymeleaf.check-template-location=true# Content-Type value. Spring.thymeleaf.content-type=text/HTML # Enable MVC Thymeleaf View resolution. Spring.thymeleaf.enabled=true# Template encoding. Spring.thymeleaf.encoding=utf-8# Comma-separated List of view names that should be excluded fromresolution. spring.thymeleaf.excluded-view-names=# Template mode to is applied to templates.  See also Standardtemplatemodehandlers. Spring.thymeleaf.mode=HTML5 # Prefix that gets prepended to view names when building a URL. Spring.thymeleaf.prefix=classpath:/templates/# Suffix that gets appended to view names when building a URL. Spring.thymeleaf.suffix=.html spring.thymeleaf.template-resolver-order= # Order of the template resolverinchThe chain. spring.thymeleaf.view-names= # comma-separated List of view names that can is resolved.

Distributed micro-service Cloud Architecture development Web application

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.