2016-11-03 218 views
-1

在一個jsp頁面上我想驗證一個文件路徑,例如我要檢查某個服務器是否存在於我已經指定了該路徑的路徑上?有人可以給這個代碼Jsp。頁面驗證...

+0

'404' - 請求的頁面不存在。這聽起來很熟悉嗎? – Arvind

回答

0

如果你想用AJAX和JavaScript做到這一點,你可以使用這個簡單的技巧。

function callstatus(){ 
    $.ajax({ 
     type: 'GET', 
     url: "http://localhost:8088/ProjectName/restController", 
     cache: false, 
     success : function(){ 
      alert("success"); 
     }, 
     statusCode: { 
      200 :function() { 
       alert('200 status code! Success '); 
      }, 
      400: function() { 
       alert('400 status code! user error'); 
      }, 
      404: function() { 
       alert('404 status code! user error'); 
      }, 
      500: function() { 
       alert('500 status code! server error'); 
      } 
     } 
    }); 
} 
+0

爲什麼HTTP 200確定「用戶錯誤」? – zack6849

+0

關於你的答案的更多澄清.....我也要jsp,任何輸入字段,我有文件的位置,將存在或不存在... – sunny

+0

只需定義好您的要求案例塞納里奧.... –