Skip to content

Commit bd8059f

Browse files
committed
add freemarker
1 parent 74a3f28 commit bd8059f

File tree

20 files changed

+247
-276
lines changed

20 files changed

+247
-276
lines changed

manong_manager/manong_manager_web/manong_manager_web.iml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
6868
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.1.3.RELEASE" level="project" />
6969
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.1.3.RELEASE" level="project" />
70-
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
7170
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.1.3.RELEASE" level="project" />
7271
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.1.3.RELEASE" level="project" />
7372
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.1.3.RELEASE" level="project" />
@@ -83,5 +82,8 @@
8382
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
8483
<orderEntry type="library" name="Maven: com.json:json:1.1" level="project" />
8584
<orderEntry type="library" name="Maven: com.baidu:ueditor:1.1.2" level="project" />
85+
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.28" level="project" />
86+
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.1.3.RELEASE" level="project" />
87+
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
8688
</component>
8789
</module>

manong_manager/manong_manager_web/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
<artifactId>ueditor</artifactId>
5454
</dependency>
5555

56+
<dependency>
57+
<groupId>org.freemarker</groupId>
58+
<artifactId>freemarker</artifactId>
59+
</dependency>
60+
61+
<dependency>
62+
<groupId>org.springframework</groupId>
63+
<artifactId>spring-context-support</artifactId>
64+
</dependency>
65+
5666
</dependencies>
5767

5868

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.manong.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.Model;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
7+
/**
8+
* Created by wistbean on 2018/12/12.
9+
*/
10+
@Controller
11+
public class FreemarkerTest {
12+
13+
@RequestMapping("/hello")
14+
public String sayHello(Model model){
15+
16+
model.addAttribute("name","wistbean");
17+
return "hello";
18+
19+
}
20+
21+
@RequestMapping("/hi")
22+
public String sayHi(Model model){
23+
24+
model.addAttribute("name","wistbean");
25+
return "hi";
26+
27+
}
28+
}

manong_manager/manong_manager_web/src/main/resources/spring/springmvc.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
55
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
66
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
7-
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
8-
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
7+
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
8+
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
99

1010
<context:component-scan base-package="com.manong.controller"></context:component-scan>
1111

1212
<mvc:annotation-driven/>
1313
<mvc:default-servlet-handler/>
1414

15+
<!--freemarker的配置在前,当当请求发现/WEB-INF/ftl/没有的时候,就会去/WEB-INF/jsp/查找-->
16+
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
17+
<property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
18+
</bean>
19+
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
20+
<property name="prefix" value=""/>
21+
<property name="suffix" value=".ftl"/>
22+
<property name="contentType" value="text/html; charset=UTF-8"/>
23+
</bean>
24+
1525
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
1626
<property name="prefix" value="/WEB-INF/jsp/"/>
1727
<property name="suffix" value=".jsp"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>hello ${name}</h1>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<%--
2+
User: wistbean
3+
Date: 2018/12/12
4+
Time: 20:25
5+
--%>
6+
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
7+
<html>
8+
<head>
9+
<title>Title</title>
10+
</head>
11+
<body>
12+
<h1>hi ${name}</h1>
13+
</body>
14+
</html>
Binary file not shown.

manong_manager/manong_manager_web/target/classes/spring/springmvc.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
55
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
66
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
7-
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
8-
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
7+
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
8+
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
99

1010
<context:component-scan base-package="com.manong.controller"></context:component-scan>
1111

1212
<mvc:annotation-driven/>
1313
<mvc:default-servlet-handler/>
1414

15+
<!--freemarker的配置在前,当当请求发现/WEB-INF/ftl/没有的时候,就会去/WEB-INF/jsp/查找-->
16+
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
17+
<property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
18+
</bean>
19+
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
20+
<property name="prefix" value=""/>
21+
<property name="suffix" value=".ftl"/>
22+
<property name="contentType" value="text/html; charset=UTF-8"/>
23+
</bean>
24+
1525
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
1626
<property name="prefix" value="/WEB-INF/jsp/"/>
1727
<property name="suffix" value=".jsp"/>

manong_manager/manong_manager_web/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
com\manong\controller\UserController.class
22
com\manong\controller\ProductCategoryController.class
3+
com\manong\controller\FreemarkerTest.class
34
com\manong\fastdfs\FastDFSClient.class
45
com\manong\controller\ProductConrtroller.class
56
com\manong\controller\PageController.class

manong_manager/manong_manager_web/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\mano
22
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\controller\ProductConrtroller.java
33
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\controller\UserController.java
44
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\controller\PageController.java
5+
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\controller\FreemarkerTest.java
56
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\fastdfs\FastDFSClient.java
67
F:\githubproject\manong\manong_manager\manong_manager_web\src\main\java\com\manong\controller\ProductCategoryController.java

0 commit comments

Comments
 (0)