Подключаем Freemarker
This commit is contained in:
10
pom.xml
10
pom.xml
@@ -102,6 +102,11 @@
|
|||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context-support</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- COMPONENTS -->
|
<!-- COMPONENTS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -130,6 +135,11 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.16.16</version>
|
<version>1.16.16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.freemarker</groupId>
|
||||||
|
<artifactId>freemarker</artifactId>
|
||||||
|
<version>2.3.23</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- TESTS -->
|
<!-- TESTS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||||
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@PropertySource("classpath:/application.properties")
|
@PropertySource("classpath:/application.properties")
|
||||||
@@ -16,4 +19,19 @@ public class SpringConfig {
|
|||||||
public WebApp webapp(@Value("${webapp.host}") String host, @Value("${webapp.port}") int port) {
|
public WebApp webapp(@Value("${webapp.host}") String host, @Value("${webapp.port}") int port) {
|
||||||
return new WebApp(host, port);
|
return new WebApp(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ViewResolver viewResolver() {
|
||||||
|
FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
|
||||||
|
viewResolver.setCache(true);
|
||||||
|
viewResolver.setSuffix(".ftl");
|
||||||
|
return viewResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FreeMarkerConfigurer freemarkerConfig() {
|
||||||
|
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
|
||||||
|
freeMarkerConfigurer.setTemplateLoaderPath("classpath:/kinosearch/kinosearch3/webpp/");
|
||||||
|
return freeMarkerConfigurer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,30 @@
|
|||||||
*/
|
*/
|
||||||
package kinosearch.kinosearch3.webpp;
|
package kinosearch.kinosearch3.webpp;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WebAppController {
|
public class WebAppController {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(WebAppController.class);
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "hello...?";
|
return "index";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/favicon.ico")
|
||||||
|
public void favicon(HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
response.sendError(404);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("favicon 404", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[#ftl]
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>KinoSearch 3.0.0-alpha</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user