Java – link from HTML to JSP
•
Java
In dynamic web projects, 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>
I also have 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>
Page hierarchy such as snapshot –
When I press default HTML, I receive an error message
- HTTP Status 404 - -------------------------------------------------------------------------------- type Status report message description The requested resource () is not available.
Solution
If you do not use the front-end controller servlet or a specific tag (such as < jsp: include >), you cannot publicly access the file in the / WEB-INF folder. It can be requestdispatcher #forward() or requestdispatcher #include()
If you need to access the JSP file directly through the URL, you should not put the JSP in the / Web - inf folder Put it outside the / WEB-INF folder
WebContent |-- forms | |-- CreateNewCustomer.html | |-- CustomerMenu.html | `-- CustomerMenu.jsp |-- WEB-INF : :
And fix the link accordingly
<a href="forms/CustomerMenu.jsp">Test new</a>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码