2

我在共享文件夹中有一个 html 文件(即,不在网络服务器位置),我必须使用 .js 将它包含在 jsp 中 <jsp:include page="//TestFolder/Sample.html">。运行应用程序时,页面上会出现以下错误:

The requested resource (/projectName//TestFolder/Sample.html) is not available 

此处应用程序名称 (/projectName) 以目标路径为前缀。如何摆脱应用程序名称以便html可以包含在jsp中?

任何澄清都将是可观的。

谢谢。

4

2 回答 2

1

Based on your comment, what you are trying to achieve is not possible with jsp inclued tag nor jsp include directive. This is because, at the end of the day, all JSPs become servlets. And a servlet with dependency outside of it's WAR (or any other packaging) would be quite tricky, now, wouldn't it?

I imagine, however, that you could create your own tag that would dynamically read a static HTML file and include it's contents in response. Just put into account that bypassing this limitation will put your application at risk of this HTML not being available unless you prepare your tag for that.

于 2012-12-13T08:03:35.057 回答
1

jsp:include操作只能在相同的 servlet 上下文中使用。它只接受相对 url(相对于页面或相对于应用程序)

于 2012-12-13T07:39:34.067 回答