2016-12-06 325 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> 
相关问题