2014-01-10 218 views
-1

好吧我有一系列的servlet我的項目JavaScript文件未找到

內如果我叫,像這樣一個servlet:

$scope.register=function() 
    { 
     $http({ 
      method : 'POST', 
      url : './registration', 
      data : "role=" + $scope.role+"&name=" + $scope.name + "&salary=" + $scope.salary+"&username=" + $scope.username + "&phone=" + $scope.phonenumber+ 
      "&password=" + $scope.pass + "&add=" + $scope.additional, 
      headers : { 
       'Content-Type' : 'application/x-www-form-urlencoded' 
      } 
     }). success(function(data) { 

       alert("changed"); 

      }). 
      error(function(data) { 
       alert("Servlet Call Error"); 
       $scope.message="Servlet call error"; 
     }); 
    } 

它的工作原理但是如果我使用工廠我404找不到

app.factory('employeeFactory', function($http){ 
return {editServlet: function(scope, http,toChange,changeTo) { 
    $http({ 
     method : 'POST', 
     url : './editInformationServlet', 
     data : 'username=' + scope.editEmp + '&toChange=' + toChange+'&changeTo='+changeTo, 
     headers : { 
      'Content-Type' : 'application/x-www-form-urlencoded' 
     } 
    }). success(function(data) { 


     }). 
     error(function(data) { 

    }); 
} 

我使用路線提供商轉到另一個頁面,這可能是問題嗎? 還是別的嗎?我真的需要幫助我的工作是在線

回答

0

我想問題是與「。」在網址前面。您應該使用以「/」開頭的絕對URL。

+0

我試過使用絕對的URL。至少我認爲這是對的。它在src/com.peterson.database.servlet/servletName – user2786754

+0

你在做什麼? servlet URL映射到web.xml中(或者與Servlet 3.0 API中的@ WebServlet註釋)。它與源文件無關。 –

+0

當我在工廠內調用我的servlet時,你必須給它url ...... – user2786754