Springboot in Template freemark,thymeleaf,jsp

Source: Internet
Author: User

Freemark templates and Thymeleaf templates 1. Introduction of Thymeleaf and Freemark in Pom.xml;
<dependency>            <groupId>org.springframework.boot</groupId>            <artifactId> Spring-boot-starter-thymeleaf</artifactid></dependency><dependency>            <groupId> Org.springframework.boot</groupid>            <artifactid>spring-boot-starter-freemarker</artifactid ></dependency>

  

2. Configuring in Application.xml
########################################################## #THYMELEAF (thymeleafautoconfiguration) ############## ########################################## #spring. thymeleaf.prefix=classpath:/templates/# spring.thymeleaf.suffix=.html#spring.thymeleaf.mode=html5#spring.thymeleaf.encoding=utf-8#;charset=< Encoding> is added#spring.thymeleaf.content-type=text/html # set to False for hot refreshspring.thymeleaf.cache= False ########################################################## #FREEMARKER (freemarkerautoconfiguration) ####### ################################################ #spring. freemarker.allow-request-override= falsespring.freemarker.cache=truespring.freemarker.check-template-location=truespring.freemarker.charset= utf-8spring.freemarker.content-type=text/htmlspring.freemarker.expose-request-attributes= falsespring.freemarker.expose-session-attributes=falsespring.freemarker.expose-spring-macro-helpers=false# spring.freemarker.prefix= #spring. freemarker.request-context-attribute= #spring. Freemarker.settings.*= #spring. freemarker.suffix=.ftl#spring.freemarker.template-loader-path=classpath:/ templates/#comma-separated list#spring.freemarker.view-names= # Whitelist of view names that can be resolved

  

3. Writing a template
Note that the path is the default in the configuration and can be modified <! DOCTYPE html>

  

4.controller Layer
Package Com.ithuan.demo.controller;import Java.util.map;import Org.springframework.stereotype.controller;import Org.springframework.web.bind.annotation.RequestMapping, @Controller//@RequestMapping ("/templates") public class Templatecontroller {@RequestMapping ("/hello1111") public String Hello1 (map<string,object> Map) { SYSTEM.ERR.PRINTLN ("----"); Map.put ("Hello", "from templatecontroller.hellohtml"); return "Hello1";} @RequestMapping ("/hello22") public String hello22 (map map) {System.err.println ("2222"); Map.put ("Hello", "final Big Boss"); return "Freemakr";}}

  

JSP page show comes with parsing no longer showing

Springboot in Template freemark,thymeleaf,jsp

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.