2011-08-06 117 views
0

我不熟悉Java和JSP。請幫我解決這個問題。jsp中的文件路徑

我在WebContent/web/jsp目錄下有兩個文件Page1.jsp和Page2.jsp。當我在Page1.jsp中單擊超鏈接(使用href標記)時,它應該導航到Page2.jsp。

這裏是下面寫的Page1.jsp代碼:

Navigate to Page2 <a href="../jsp/Page2.jsp">here</a> 

我用下面的路徑也:

Navigate to Page2 <a href="../web/jsp/Page2.jsp">here</a> 

無論是時間,我收到錯誤"The requested resource (/Sample/web/jsp/Page2.jsp) is not available".

「示例'是我在web.xml中指定的項目名稱。我正在使用Tomcat 6.0服務器。

請幫我解決這個問題。

回答

0

如果這兩個.jsp文件位於同一文件夾中,請不要包含文件夾名稱。

例如

導航到第2頁<a href="Page2.jsp">here</a>

0

導航到Page2.jsp可以這樣做。

<a href="<%=request.getContextPath() %>/web/jsp/Page2.jsp">here</a>