gpt4 book ai didi

java - 从html链接到jsp

转载 作者:太空狗 更新时间:2023-10-29 14:47:49 25 4
gpt4 key购买 nike

在动态 Web 项目中我有 - default.html 页面

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
<a href="\WEB-INF\forms\CustomerMenu.jsp">Test new</a>

</body>
</html>

我还有 CustomerMenu.jsp 页面 -

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
// Table ..
</body>
</html>

页面层次结构如快照 -

enter image description here

当我点击 default.html 中的链接时,我收到错误消息

- HTTP Status 404 - 

--------------------------------------------------------------------------------

type Status report

message

description The requested resource () is not available.

最佳答案

/WEB-INF 中的文件不使用前端 Controller 就无法公开访问文件夹 servlet或特定标签,如 <jsp:include>这要么是一个 RequestDispatcher#forward() RequestDispatcher#include() .

如果您需要通过 URL 直接访问 JSP 文件,那么您不应该将 JSP 放在 /WEB-INF 中文件夹。把它放在 /WEB-INF 外面文件夹

WebContent
|-- forms
| |-- CreateNewCustomer.html
| |-- CustomerMenu.html
| `-- CustomerMenu.jsp
|-- WEB-INF
: :

并相应地修复链接。

<a href="forms/CustomerMenu.jsp">Test new</a>

关于java - 从html链接到jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11779721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com