Browse Source

spring-boot-template-freemarker 完成

pull/1/head
Yangkai.Shen 6 years ago
parent
commit
ef59e18d80
13 changed files with 19 additions and 15 deletions
  1. +0
    -0
      spring-boot-demo-template-freemarker/.gitignore
  2. +1
    -1
      spring-boot-demo-template-freemarker/README.md
  3. +3
    -3
      spring-boot-demo-template-freemarker/pom.xml
  4. +2
    -2
      spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/SpringBootDemoTemplateFreemarkerApplication.java
  5. +1
    -1
      spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/IndexController.java
  6. +1
    -1
      spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/UserController.java
  7. +0
    -0
      spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/model/User.java
  8. +8
    -0
      spring-boot-demo-template-freemarker/src/main/resources/application.yml
  9. +0
    -0
      spring-boot-demo-template-freemarker/src/main/resources/templates/common/head.ftl
  10. +1
    -1
      spring-boot-demo-template-freemarker/src/main/resources/templates/page/index.ftl
  11. +1
    -1
      spring-boot-demo-template-freemarker/src/main/resources/templates/page/login.ftl
  12. +1
    -1
      spring-boot-demo-template-freemarker/src/test/java/com/xkcoding/template/freemarker/SpringBootDemoTemplateFreemarkerApplicationTests.java
  13. +0
    -4
      spring-boot-template-freemarker/src/main/resources/application.yml

spring-boot-template-freemarker/.gitignore → spring-boot-demo-template-freemarker/.gitignore View File


spring-boot-template-freemarker/README.md → spring-boot-demo-template-freemarker/README.md View File

@@ -1,4 +1,4 @@
# spring-boot-template-freemarker
# spring-boot-demo-template-freemarker


> 本 demo 主要演示了 Spring Boot 项目如何集成 freemarker 模板引擎 > 本 demo 主要演示了 Spring Boot 项目如何集成 freemarker 模板引擎



spring-boot-template-freemarker/pom.xml → spring-boot-demo-template-freemarker/pom.xml View File

@@ -4,11 +4,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>


<groupId>com.xkcoding</groupId> <groupId>com.xkcoding</groupId>
<artifactId>spring-boot-template-freemarker</artifactId>
<artifactId>spring-boot-demo-template-freemarker</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>


<name>spring-boot-template-freemarker</name>
<name>spring-boot-demo-template-freemarker</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>


<parent> <parent>
@@ -55,7 +55,7 @@
</dependencies> </dependencies>


<build> <build>
<finalName>spring-boot-template-freemarker</finalName>
<finalName>spring-boot-demo-template-freemarker</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

spring-boot-template-freemarker/src/main/java/com/xkcoding/template/freemarker/SpringBootTemplateFreemarkerApplication.java → spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/SpringBootDemoTemplateFreemarkerApplication.java View File

@@ -17,9 +17,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @modified: yangkai.shen * @modified: yangkai.shen
*/ */
@SpringBootApplication @SpringBootApplication
public class SpringBootTemplateFreemarkerApplication {
public class SpringBootDemoTemplateFreemarkerApplication {


public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SpringBootTemplateFreemarkerApplication.class, args);
SpringApplication.run(SpringBootDemoTemplateFreemarkerApplication.class, args);
} }
} }

spring-boot-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/IndexController.java → spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/IndexController.java View File

@@ -34,7 +34,7 @@ public class IndexController {
if (ObjectUtil.isNull(user)) { if (ObjectUtil.isNull(user)) {
mv.setViewName("redirect:/user/login"); mv.setViewName("redirect:/user/login");
} else { } else {
mv.setViewName("index");
mv.setViewName("page/index");
mv.addObject(user); mv.addObject(user);
} }



spring-boot-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/UserController.java → spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/controller/UserController.java View File

@@ -40,6 +40,6 @@ public class UserController {


@GetMapping("/login") @GetMapping("/login")
public ModelAndView login() { public ModelAndView login() {
return new ModelAndView("login");
return new ModelAndView("page/login");
} }
} }

spring-boot-template-freemarker/src/main/java/com/xkcoding/template/freemarker/model/User.java → spring-boot-demo-template-freemarker/src/main/java/com/xkcoding/template/freemarker/model/User.java View File


+ 8
- 0
spring-boot-demo-template-freemarker/src/main/resources/application.yml View File

@@ -0,0 +1,8 @@
server:
port: 8080
servlet:
context-path: /demo
spring:
freemarker:
suffix: .ftl
cache: false

spring-boot-template-freemarker/src/main/resources/templates/common/head.ftl → spring-boot-demo-template-freemarker/src/main/resources/templates/common/head.ftl View File


spring-boot-template-freemarker/src/main/resources/templates/index.ftl → spring-boot-demo-template-freemarker/src/main/resources/templates/page/index.ftl View File

@@ -1,6 +1,6 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<#include "./common/head.ftl">
<#include "../common/head.ftl">
<body> <body>
<div id="app" style="margin: 20px 20%"> <div id="app" style="margin: 20px 20%">
欢迎登录,${user.name}! 欢迎登录,${user.name}!

spring-boot-template-freemarker/src/main/resources/templates/login.ftl → spring-boot-demo-template-freemarker/src/main/resources/templates/page/login.ftl View File

@@ -1,6 +1,6 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<#include "./common/head.ftl">
<#include "../common/head.ftl">
<body> <body>
<div id="app" style="margin: 20px 20%"> <div id="app" style="margin: 20px 20%">
<form action="/demo/user/login" method="post"> <form action="/demo/user/login" method="post">

spring-boot-template-freemarker/src/test/java/com/xkcoding/template/freemarker/SpringBootTemplateFreemarkerApplicationTests.java → spring-boot-demo-template-freemarker/src/test/java/com/xkcoding/template/freemarker/SpringBootDemoTemplateFreemarkerApplicationTests.java View File

@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;


@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
public class SpringBootTemplateFreemarkerApplicationTests {
public class SpringBootDemoTemplateFreemarkerApplicationTests {


@Test @Test
public void contextLoads() { public void contextLoads() {

+ 0
- 4
spring-boot-template-freemarker/src/main/resources/application.yml View File

@@ -1,4 +0,0 @@
server:
port: 8080
servlet:
context-path: /demo

Loading…
Cancel
Save