【发布时间】:2018-09-03 18:49:31
【问题描述】:
我想用我的 Spring Boot 应用程序提供国际化的 html 页面,我正在使用 Thymeleaf 和 messages_XX.properties 用于 i18n。我更喜欢以http://localhost:8080/some/path/test.html 的身份访问这些并将它们放入例如/src/main/resources/html 但我无法将 Spring Boot 配置为默认使用 thymeleaf 处理页面。
作为临时解决方法,我有一个控制器
@RequestMapping(value="**/*.html")
public String serve(HttpServletRequest req) {
String res = req.getRequestURI().substring(0, req.getRequestURI().length() - 5);
res = res.substring(1);
return res;
}
现在这对我有用:http://localhost:8080/some/path/file.html 处理和服务src/templates/some/path/file.html,但我可以在某个地方配置 src/resources/html 将由 thymeleaf 处理然后服务吗?
到目前为止我已经尝试过
spring.thymeleaf.prefix=classpath:/html/
在application.properties,但它似乎对我不起作用。
环境:
spring-boot-starter-2.0.0.RELEASE,
spring-webmvc-5.0.4.RELEASE,
thymeleaf-spring5-3.0.9.RELEASE
【问题讨论】:
标签: spring spring-mvc spring-boot thymeleaf