2016-06-05 9 views
0

Also ich bin derzeit einC: URL anhängt nicht localhost meine Javascript-Datei

Cross origin requests are only supported for HTTP. 

bekommen es Nachdem ich eine Weile ich um zu bestimmen, konnte es passiert, wenn Sie versuchen, JavaScript-Dateien aus lokalen hochladen und nicht http, dass das Problem auftritt.

Mein jsp auf Back-End-

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<html> 
    <head> 
    <title>Product Finder</title> 
    </head> 
    <body ng-app="myProductFinder"> 

     <div class="generic-container" ng-controller="UserController as ctrl"> 
     <form ng-submit="ctrl.submit()" name="myForm" class="form-horizontal"> 
      <input type="text" ng-model="ctrl.searchString" id="uname" class="username form-control input-sm" placeholder="Enter your name" required/> 

      <input type="submit" value="Search" class="btn btn-primary btn-sm"> 
     </form>        

     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script> 
     <script src="<c:url value='/static/js/app.js' />"></script> 
     <script src="<c:url value='/static/js/service/productSearchService.js' />"></script> 
     <script src="<c:url value='/static/js/controller/productSearchController.js' />"></script> 
    </body> 
</html> 

Meine gerenderte Seite auf fron Ende Quelle

<html> 
    <head> 
    <title>Product Finder</title> 
    </head> 
    <body ng-app="myProductFinder"> 

     <div class="generic-container" ng-controller="UserController as ctrl"> 
     <form ng-submit="ctrl.submit()" name="myForm" class="form-horizontal"> 
      <input type="text" ng-model="ctrl.searchString" id="uname" class="username form-control input-sm" placeholder="Enter your name" required/> 

      <input type="submit" value="Search" class="btn btn-primary btn-sm"> 
     </form>        

     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script> 
     <script src="/searchMart/static/js/app.js"></script> 
     <script src="/searchMart/static/js/service/productSearchService.js"></script> 
     <script src="/searchMart/static/js/controller/productSearchController.js"></script> 
    </body> 
</html> 

Wenn man sich das Skript schaut auf den letzten 3 Zeilen ist es zu lokalem Pfad zeigt und nicht durch localhost, was ich erwarten würde, dass es durchgeht. Ich benutze Anlegesteg, um es zu führen. Wer weiß, warum es nicht die lokale Host-URL

Antwort

0

ich nicht putting http: // in meinem bekomme Anfrage in meinem Service js.

$http.get('http://localhost:8080/searchMart/index/search',productName) 
Verwandte Themen