zoukankan      html  css  js  c++  java
  • Spring boot 梳理

    1. 开发环境中关闭缓存
      1. spring:
            thymeleaf:
                cache: false
            freemarker:
                cache: false
    2. Spring boot 集成 freemarker
      1.         <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-freemarker</artifactId>
                </dependency>
      2. oa/src/main/resources/templates/hello.ftl
        1. <!DOCTYPE html>  
          <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  
                xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">  
              <head>  
                  <title>Hello World!</title>  
              </head>  
              <body>
                 <center>
                 OK
                 </center>
              </body>  
          </html>
      3. @Controller
        1. @Controller
          @RequestMapping("/fruit")
          public class FruitController {
              @RequestMapping(value="{fruitName}", method = RequestMethod.GET)
              public String getFruit(@PathVariable String fruitName, ModelMap model) {
          
                  //Fruit fruit = new Fruit(fruitName, 1000);
                  HashMap<String,String> fruit=new HashMap<String,String>();
                  fruit.put("fruit", "fruit");
                  model.addAttribute("model", fruit);
                  
                  return "hello";
          
              }
          }
      4. 访问
        1. http://localhost:8080/fruit/a
        2. 显示 OK
      5. 可以设置freemarker属性
        1. application.properties
        2. spring.freemarker.allow-request-override=false
          spring.freemarker.cache=false
          spring.freemarker.check-template-location=true
          spring.freemarker.charset=UTF-8
          spring.freemarker.content-type=text/html
          spring.freemarker.expose-request-attributes=false
          spring.freemarker.expose-session-attributes=false
          spring.freemarker.expose-spring-macro-helpers=false
  • 相关阅读:
    php类型运算符
    今天我开始写自己的东西
    挑选简历
    SQL Server和Oracle数据库索引介绍
    排序算法分析与设计实验
    软件框架 转
    【转】Ajax的原理和应用
    Web Service
    [转]异地分布式敏捷软件开发(Distributed Agile Software Development)
    [转]如何有效的使用C#读取文件
  • 原文地址:https://www.cnblogs.com/jiangtao1218/p/10206297.html
Copyright © 2011-2022 走看看