有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

未显示jsp Java头

我有一个头球。jsp在我的布局中。但它并没有在浏览器中得到反映,甚至在刷新缓存后也尝试了mozilla和ie

头球。jsp内容---

<h1>Login Application</h1>

布局。jsp内容--

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator"
    prefix="decorator"%>

<%@page contentType="text/html; charset=UTF-8"%>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />


</head>

<body>
<div>
 <jsp:include page="/WEB-INF/includes/header.jsp"/>
</div>


<div  ><decorator:body /></div>



</body>
</html>

共 (1) 个答案

  1. # 1 楼答案

    这是因为它在WEB-INF目录中

    HTTP服务器无法访问WEB-INF中的所有内容。通过对服务器的HTTP请求调用jsp:include,但目标文件是不允许提供服务的,因此您什么也得不到

    如果您真的想按原样使用该文件,可以使用:

     <%@ include file="/WEB-INF/includes/header.jsp" %>
    

    因为这将在编译时得到评估,编译器能够访问该文件

    或者您可以将jsp移动到web服务器可以访问的文件中,比如/includes/,它是WEB-INF.的同级

    <jsp:include page="/includes/header.jsp"/>
    

    此外,请确保该文件具有适当的权限,以便服务器可以访问它