Html 如何在html中包含jsp页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15865250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:18:58  来源:igfitidea点击:

how can i include jsp page in html?

htmljspnetbeans

提问by Parth Joshi

I am using Netbeans and MySql server. I want to add JSP content into an HTML file. How can I include it?

我正在使用 Netbeans 和 MySql 服务器。我想将 JSP 内容添加到 HTML 文件中。我怎样才能包括它?

回答by JB Nizet

Make the HTML file a JSP page, and use a JSP include (static or dynamic, depending on what you want, but you probably want a static include here):

使 HTML 文件成为 JSP 页面,并使用 JSP 包含(静态或动态,取决于您想要什么,但您可能需要在此处使用静态包含):

<%@include file="theJspToInclude.jsp" %>

HTML files are static resources that are served as is, without any kind of interpretation, by the web container.

HTML 文件是静态资源,由 Web 容器按原样提供,没有任何类型的解释。

回答by Rengasami Ramanujam

JSP is a dynamic one. It needs a web container to get executed. Why do you need to include it in a static html page. To my knowledge, if you want to include a jsp page in a html page, then your page is intended to be dynamic. So you have to change that to be a JSP page. Now you can use

JSP 是一个动态的。它需要一个 Web 容器来执行。为什么需要将它包含在静态 html 页面中。据我所知,如果您想在 html 页面中包含一个 jsp 页面,那么您的页面应该是动态的。因此,您必须将其更改为 JSP 页面。现在你可以使用

<%@include file="includeable.jsp" %>

This will include your jsp.

这将包括您的jsp。

You cannot include a JSP to a HTML page.

不能在 HTML 页面中包含 JSP。