2016-12-27 80 views
0

这就是我想要做的:用户上传一堆html文件作为zip压缩文件。我解压该档案并在网站上显示html内容。包含用户上传的html文件

为此,我想将html内容包含在thymeleaf页面中。到目前为止,我已经试过这样:

<div th:include="http://localhost:8181/MySpringApp/uploads/include.html"></div> 
<div th:include="@{/uploads/include.html}"></div> 
<div th:include="@{~/uploads/include.html}"></div> 

在所有这三种情况下,我得到以下错误(具有不同URL):

Exception processing template "dashboard": Error resolving template "/uploads/include.html", template might not exist or might not be accessible by any of the configured Template Resolvers (dashboard:40) 

我将如何得到这个工作?我只看到了包含template文件夹中的静态文件的示例。但那不是我想要做的。

我使用Wildfly 9和standalone/data文件夹我创建了uploads文件夹。

回答

0

这样的代码应该工作:

<div th:include="@{/uploads/include}"></div> 
+0

感谢您的回复,我编辑了我的问题。 – user3813234

0

难道是一个在未经许可的问题?我只是想知道,因为你说某些外部用户可以上传这些文件,所以你可能没有正确的许可来显示或使用它们。

希望它有帮助!

+0

感谢您的回复。我编辑了我的问题。 – user3813234

0

假设你uploads文件夹templates下,插入HTML为:

<div th:insert="~{uploads/include}"></div> 

顺便说一句,由于Thymeleaf 3.0不建议th:include

+0

感谢您的回复。我编辑了我的问题。 – user3813234