从html链接到jsp

URL*_*L87 6 html java jsp href

在动态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>
Run Code Online (Sandbox Code Playgroud)

我还有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>
Run Code Online (Sandbox Code Playgroud)

页面层次结构如快照 -

在此输入图像描述

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

- HTTP Status 404 - 

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

type Status report

message 

description The requested resource () is not available.
Run Code Online (Sandbox Code Playgroud)

Bal*_*usC 10

在文件/WEB-INF夹也不是没有使用前端控制器可公开访问的servlet或一个特定的标签就像<jsp:include>它确实无论是RequestDispatcher#forward()RequestDispatcher#include().

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

WebContent
 |-- forms
 |    |-- CreateNewCustomer.html
 |    |-- CustomerMenu.html
 |    `-- CustomerMenu.jsp
 |-- WEB-INF
 :    :
Run Code Online (Sandbox Code Playgroud)

并相应地修复链接.

<a href="forms/CustomerMenu.jsp">Test new</a>
Run Code Online (Sandbox Code Playgroud)