我有一个看起来像这样的 jsp 文件:
<html>
<body>
<div>location: ${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/</div>
<div>(should have "verdagon.net" somewhere in there)</div>
<div>Included stuff should appear below here:</div>
<jsp:include page="toinclude.html"/>
</body>
</html>
当我的 WEB-INF 目录中没有 web.xml 时,它会正确输出:
location: http://verdagon.net:80/strnowebxml/
(should have "verdagon.net" somewhere in there)
Included stuff should appear below here:
I'm included!
然而,当我添加一个 WEB-INF 目录时,我放了一个简单的 web.xml,里面只有这个,
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
随着 web.xml 的出现,我得到了这个输出:
location: ${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/
(should have "verdagon.net" somewhere in there)
Included stuff should appear below here:
I'm included!
问题是:这些美元符号替换没有发生。
奇怪的是:我知道 JSP 正在运行,因为 jsp:include 运行良好。
任何人都知道为什么没有 web.xml 时 JSP 工作,然后当我添加它时中断?