2015-11-24 65 views
0

我通過Javascript提交表單作爲document.videoReleaseForm.submit();Servlet的不可達

和形式的定義是:<form name="videoReleaseForm" id="videoReleaseForm" action="studController">

當控制到達javascript代碼,並試圖將其提交給servlet,我得到的消息如:You don't have permission to access /student/studController on this server.

這裏有什麼問題。

+0

不太可能是JavaScript。你能否在沒有它的情況下提交表格?聽起來像你可能需要在服務器上設置權限 – mplungjan

+0

@mplungjan:提交之前的JavaScript代碼進行一些檢查並設置幾個變量並提交它。順便說一句我正在運行tomcat7。我們可以在哪裏設置服務器的權限。 –

+0

https://www.google.com/search?q=You+don't+have+permission+to+access+on+this+server+tomcat – mplungjan

回答

0

這樣做的一種方式是在javascript函數中返回true/false,並使用form的「onsubmit」。

<form name="videoReleaseForm" id="videoReleaseForm" action="studController" onsubmit="return validate()"> 

並在「驗證」javascript函數中,返回true或false。

true將把操作傳遞給servlet,false將不會。

我做了類似的實現,它的工作原理。