牙科诊所信息管理系统 : 一. 创建springboot 框架集成freemarker

GitHub地址:https://github.com/mayanze/mayanze-dcims

背景:mayanze-dcims是根据"2019软件设计师"真题第3道大题所做的一套信息管理系统, dcims是Dental Clinic Information Management system(牙科诊所信息管理系统) 缩写;使用springboot,freemarker,miniui构件项目。 看了FreeMarker、Thymeleaf、Enjoy 模板引擎性能测试 ,这篇文章,决定了选择FreeMarker

开搞:

1. 使用IntelliJ IDEA使用 Spring Initializr 创建spring boot 框架, 傻瓜式操作,下一步下一步直到完成

2.集成freemarker

1) 引入maven依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

2)application.yml

server:
  #访问端口号  
  port: 8080  
  servlet:
    #请求路径    
    context-path: /dcims

你一定很奇怪怎么没有 freemarker 的配置,类似这种配置   ,请看这里,只要你符合默认配置就不需要再另外配置

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.springframework.boot.autoconfigure.freemarker;

import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(
    prefix = "spring.freemarker"
)
public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties {
    public static final String DEFAULT_TEMPLATE_LOADER_PATH = "classpath:/templates/";
    public static final String DEFAULT_PREFIX = "";
    public static final String DEFAULT_SUFFIX = ".ftlh";
    private Map<String, String> settings = new HashMap();
    private String[] templateLoaderPath = new String[]{"classpath:/templates/"};
    private boolean preferFileSystemAccess = true;

    public FreeMarkerProperties() {
        super("", ".ftlh");
    }

    public Map<String, String> getSettings() {
        return this.settings;
    }

    public void setSettings(Map<String, String> settings) {
        this.settings = settings;
    }

    public String[] getTemplateLoaderPath() {
        return this.templateLoaderPath;
    }

    public boolean isPreferFileSystemAccess() {
        return this.preferFileSystemAccess;
    }

    public void setPreferFileSystemAccess(boolean preferFileSystemAccess) {
        this.preferFileSystemAccess = preferFileSystemAccess;
    }

    public void setTemplateLoaderPath(String... templateLoaderPaths) {
        this.templateLoaderPath = templateLoaderPaths;
    }
}

3)创建一个controller

package org.mayanze.dcims.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 用户
 * author: mayanze
 * date: 2020/9/18 4:20 下午
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @GetMapping("/page")
    public String userPage(){
        return "page";
    }
}

4)创建一个page.ftlh,注意后缀【.ftlh】,必须要上述默认配置一样,以及所写位置

5)启动项目,浏览器访问 http://localhost:8080/dcims/user/page

下一篇:牙科诊所信息管理系统 : 二. 集成MiniUI 3.9.4

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值