2016-12-06 355 views
1

所以我剛剛使用Eclipse和SAP UI5創建了一個項目。服務器響應狀態爲404(無法找到資源!)SAPUI5

這是我的index.html

<html> 
    <head> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/> 

     <script src="resources/sap-ui-core.js" 
       id="sap-ui-bootstrap" 
       data-sap-ui-libs="sap.m" 
       data-sap-ui-theme="sap_bluecrystal" 
       data-ui-resourceroots='{"sap.myApp":"./"}'> 
     </script> 
     <!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme --> 

     <script type="text/javascript"> 

     sap.ui.getCore().attachInit(function() 
       { 
      sap.ui.xmlview({ 
       viewName: "sap.myApp.view.App" 
      }).placeAt("content"); 
       }); 
     </script> 

    </head> 
    <body class="sapUiBody" role="application"> 
     <div id="content"></div> 
    </body> 
</html> 

這是我的控制器命名App.Controller.js

 sap.ui.controller("sap.myApp.controller.App", { 



}); 

,並查看被命名爲App.view.xml

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" 
    controllerName="sap.myApp.controller.App" xmlns:html="http://www.w3.org/1999/xhtml"> 
<Page title="Title"> 
    <content> 
<Image src="http://www.w3schools.com/css/img_fjords.jpg"/> 
    </content> 
</Page> 

現在whe ñ我嘗試運行它,我得到這個錯誤。

sap-ui-core.js:126 GET http://localhost:55694/HelloWorld/resources/sap/myApp/view/App.view.xml 404 (Resource could not be found!)send @ sap-ui-core.js:126ajax @ sap-ui-core.js:126q.sap.loadResource @ sap-ui-core.js:174f.initViewSettings @ library-preload.js:907c._initCompositeSupport @ library-preload.js:862(anonymous function) @ sap-ui-core.js:461constructor @ sap-ui-core.js:461constructor @ sap-ui-core.js:971constructor @ sap-ui-core.js:805f @ sap-ui-core.js:638f @ sap-ui-core.js:638sap.ui.view @ library-preload.js:881sap.ui.xmlview @ library-preload.js:891o.(anonymous function) @ sap-ui-core.js:393(anonymous function) @ index.html:19(anonymous function) @ sap-ui-core.js:861each @ sap-ui-core.js:115w._executeInitListeners @ sap-ui-core.js:861w.init @ sap-ui-core.js:856w.handleLoad @ sap-ui-core.js:862(anonymous function) @ sap-ui-core.js:838l @ sap-ui-core.js:172S.finishTask @ sap-ui-core.js:172(anonymous function) @ sap-ui-core.js:838p @ sap-ui-core.js:126fireWith @ sap-ui-core.js:126ready @ sap-ui-core.js:126V @ sap-ui-core.js:126 
sap-ui-core.js:174 Uncaught Error: resource sap/myApp/view/App.view.xml could not be loaded from resources/sap/myApp/view/App.view.xml. Check for 'file not found' or parse errors. Reason: Resource could not be found!(…) 

有人可以告訴我,我做錯了什麼?

謝謝。

回答

3

正確的屬性名稱是data-sap-ui-resourceroots。但是,您的應用程序還有另一個問題。除非您正在開發SAPUI5/OpenUI5內容,否則不得使用命名空間sap。請檢查documentation

0

sap.myApp命名空間的目錄映射不起作用。映射屬性名爲data-sap-ui-resourceroots

<script src="resources/sap-ui-core.js" 
      id="sap-ui-bootstrap" 
      data-sap-ui-libs="sap.m" 
      data-sap-ui-theme="sap_bluecrystal" 
      data-sap-ui-resourceroots='{"sap.myApp":"./"}'> 
</script> 
相關問題