zoukankan      html  css  js  c++  java
  • springboot-整合freemarker

    1、添加依赖:pom.xml

    <!--freemarker依赖,模板引擎-->
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>

    2、配置文件:application.properties

    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mysql-boot
    spring.datasource.username=root
    spring.datasource.password=123123
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    
    spring.freemarker.suffix=.ftl
    spring.freemarker.templateEncoding=UTF-8
    spring.freemarker.templateLoaderPath=classpath:/templates/
    spring.freemarker.content-type=text/html
    spring.freemarker.request-context-attribute=request

    3、controller

    @RequestMapping("getStudents/{name}")
        public String getStudents(ModelMap map, @PathVariable String name){
            .....
            return "views/student";
        }

    4、ftl文件

    <!--获取项目路径springMacroRequestContext或${request.contextPath}-->
        <#assign path= springMacroRequestContext.getContextPath()/>
        <script src="${path}/js/jquery.js" type="text/javascript"></script><script src="${request.contextPath}/js/jquery.js" type="text/javascript"></script>
  • 相关阅读:
    F
    Common Subsequence
    Neighbor House
    Robberies(背包)
    Stock Exchange(LIS最长上升子序列问题)
    Compromise(LCS)
    POJ-3356 AGTC (最短编辑距离问题)
    Monkey and Banana(LIS最长上升子序列)
    网络编程之网络协议
    面向对象高级
  • 原文地址:https://www.cnblogs.com/lijianda/p/11052530.html
Copyright © 2011-2022 走看看