问题描述
我对JSP有点新鲜,并且在理解JSP中的以下包含代码可能出问题的地方时遇到了问题:
I am a bit fresh to JSP and I am having problems understanding what could be wrong with the following include code within my JSP:
../test-project/main.jsp
../test-project/main.jsp
<jsp:include page="../blueprint-project/header-includes.jsp"/>
<!-- More HTML/CSS code below which is working and not blocking -->
../blueprint-project/header-include.jsp
../blueprint-project/header-include.jsp
<%@ taglib uri="struts-sslext" prefix="sslext" %>
<%@ page import="mts.psp.web.struts.util.WebSessionUtil" %>
<%@ page import="mts.psp.web.struts.util.ActionUtil" %>
<%@ page import="mts.psp.metrics.entity.TestGroup" %>
<%@ page import="mts.psp.util.common.ConfigUtil" %>
<%@ taglib uri="struts-tiles" prefix="tiles" %>
<%@ taglib uri="struts-html" prefix="html" %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="struts-bean" prefix="bean" %>
<%@ taglib uri="jstl-core" prefix="c" %>
header-include.jsp中的代码先前位于页面顶部的main.jsp中.我想做的是获取此代码,将其放在另一个.jsp文件(名为header-include.jsp)中,并动态地将其包含在main.jsp中.
The code in header-include.jsp previously existed within main.jsp at the top of the page. What I am trying to do is take this code, put it in another .jsp file (named header-include.jsp) and have it dynamically included into main.jsp
当我尝试执行此操作时,出现500错误.我正在尝试做的事情完全可能/正确吗?社区的任何帮助都是杰出的.
When I attempt to do this, I get a 500 error. Is what I am attempting to do possible/correct at all? Any help from the community would be outstanding.
推荐答案
看来我要做的就是使用静态包含,如注释中所建议:
It seems all I had to do was to use a static include, as suggested in the comments:
<%@ include file="../blueprint-project/header-includes.jsp" %>
Static include允许我在翻译时将header-includes.jsp
的内容添加到当前页面中. oracle文档 以及 此堆栈溢出答案 .
Static include allowed me to add the content of header-includes.jsp
at translation time into the current page. This is clearly evidenced in the oracle docs as well as this stack overflow answer.
这篇关于正确包含另一个JSP文件中的JSP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!