微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 从html链接到jsp

在动态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>

页面层次结构如快照 –

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

- HTTP Status 404 - 

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

type Status report

message 

description The requested resource () is not available.

解决方法

如果不使用前端控制器 servlet或特定标签(如< jsp:include>),则无法公开访问/ WEB-INF文件夹中的文件它可以是 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>

原文地址:https://www.jb51.cc/java/120470.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐