结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

├─java
│ └─com
│ └─kreedx
│ └─alishop
│ │ Boot.java
│ │
│ ├─utils
│ │ AliShop.java
│ │
│ └─web
│ FreeMakerTest.java
│ Test.java

├─resources
│ │ application.properties
│ │
│ ├─templates
│ │ test.html
│ │
│ └─templates2
│ test.ftl

└─webapp
└─WEB-INF

application.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

server.port=8080
server.session-timeout=30
server.tomcat.uri-encoding=UTF-8


spring.thymeleaf.prefix=classpath:templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

logging.file=log.log
logging.level.com.xiaofangtech.sunt.controller = debug
logging.level.com.xiaofangtech.sunt.helper = warn


spring.freemarker.template-loader-path=classpath:/templates2/
spring.mvc.static-path-pattern=/static/**

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kreedx</groupId>
<artifactId>Alipay</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Alipay Maven Webapp</name>
<url>http://maven.apache.org</url>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.alipay</groupId>
<artifactId>alipy-sdk</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>

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


</dependencies>
<build>
<finalName>Alipay</finalName>
</build>
</project>

FreeMakerTest.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@RequestMapping("free")
@Controller
public class FreeMakerTest {

@RequestMapping("/")
public String helloHtml(Map<String, Object> map) {

map.put("hello", "from TemplateController.helloHtml");
return "/test";
}

@RequestMapping("/test")
public String getTest(Model model){
model.addAttribute("name", "kreedx");
return "/test";
}
}