从html链接到jsp [英] link from html to jsp
问题描述
在动态Web项目中,我有-default.html页面
In dynamic Web Project I have - default.html page
<!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页面-
I have also the CustomerMenu.jsp page -
<!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>
页面层次结构作为快照-
The pages hierarchy is as the snapshot -
当我按下default.html中的链接时,我收到错误消息
When I press on the link in default.html I get error message
- HTTP Status 404 -
--------------------------------------------------------------------------------
type Status report
message
description The requested resource () is not available.
推荐答案
如果不使用前端控制器,则不能公开访问/WEB-INF
文件夹中的文件 RequestDispatcher#forward()
或
Files in /WEB-INF
folder are not publicly accessible without using a front controller servlet or a specific tag like <jsp:include>
which does either a RequestDispatcher#forward()
or RequestDispatcher#include()
.
如果需要通过URL直接访问 JSP文件,则不应将JSP放在/WEB-INF
文件夹中.将其放在/WEB-INF
文件夹
If you need to access a JSP file directly by URL, then you should not be placing the JSP in /WEB-INF
folder. Put it outside the /WEB-INF
folder
WebContent
|-- forms
| |-- CreateNewCustomer.html
| |-- CustomerMenu.html
| `-- CustomerMenu.jsp
|-- WEB-INF
: :
并相应地修复链接.
<a href="forms/CustomerMenu.jsp">Test new</a>
这篇关于从html链接到jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!