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
  • 相关阅读:
    C指针详解(经典,非常详细)
    PL/SQL错误提示 database character set(AL32UTF8) and Client character set(ZHS16GBK) are different
    安装Oracle报错,全部为未知!
    Oracle 支持在具有 DHCP 分配的 IP 地址的系统上进行安装
    Asp.Net页面生命周期
    oracle 导库建立测试库
    宝塔安装建站教程
    SEM理论
    SEM小总结
    SEM大致操作梳理
  • 原文地址:https://www.cnblogs.com/jiangtao1218/p/10206297.html
Copyright © 2011-2022 走看看