0

有以下jsp页面-

default.jsp在下面WebContent

EmployeeMenu.jsp在下面WebContent/MenuPages

selectAccountToRemoveOwner.jsp在下面WebContent/ActionsPages

我在 servlet 和 jsp 页面之间运行以下命令-

首先default.jsp ——

<html>
<head>
<link rel="stylesheet" href="Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
    </script>
    <form action="loginCheckServlet" method="POST">
        //form ... 
    </form>

</body>
</html>

去 -loginCheckServletdoPost-

protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

            // forward to employee page ..
            String addressMenuPage = "MenuPages/"
                    +"EmployeeMenu.jsp";
            RequestDispatcher dispather = 
                    request.getRequestDispatcher(addressMenuPage);
            // go to this page ...
            dispather.forward(request, response) ; 
    }

前往EmployeeMenu.jsp——

<html>
<head>
</head>
<body>
           <a href="ActionsPages/selectAccountToRemoveOwner.jsp">Remove owner from
                    account</a>
</body>
</html>

selectAccountToRemoveOwner.jsp-

<html>
<head>
</head>
<body>
    <a href="../MenuPages/EmployeeMenu.jsp">Return to Employee menu</a>

</body>
</html>

回到EmployeeMenu.jsp.

直到这里所有的链接都可以正常工作。但是现在,如果我再次按下链接EmployeeMenu.jsp以进入,selectAccountToRemoveOwner.jsp我会得到 -

HTTP Status 404 - /MyBankProject/MenuPages/ActionsPages/selectAccountToRemoveOwner.jsp

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

type Status report

message /MyBankProject/MenuPages/ActionsPages/selectAccountToRemoveOwner.jsp

description The requested resource (/MyBankProject/MenuPages/ActionsPages/selectAccountToRemoveOwner.jsp) is not available.

请注意,该消息指的/MenuPages/ActionsPages是确实不存在的位置。似乎从EmployeeMenu.jsp到的过渡selectAccountToRemoveOwner.jsp并没有改变当前的文件夹位置。

4

1 回答 1

0

简单的答案似乎是修改 EmployeeMenu.jsp 文件中链接的 href,使其看起来像这样:

<a href="../ActionsPages/selectAccountToRemoveOwner.jsp">

EmployeeMenu.jsp 中的相对链接被附加到我认为是“/MyBankProject/MenuPages/”的当前上下文路径中。

于 2012-08-15T14:47:37.353 回答