我想用我的Spring Boot应用程序提供国际化的html页面,我正在使用Thymeleaf和 messages_XX.properties
for i18n . 我更愿意将它们作为http://localhost:8080/some/path/test.html访问并将它们放在例如 /src/main/resources/html
但我默认情况下无法配置Spring Boot来使用百万富翁处理页面 .
作为临时解决方法,我有一个控制器
@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
将被百里香叶处理然后服务吗?
到目前为止我已经尝试过
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
1 回答
因为你正在切割.html:
你可能应该设置
或配置: