在SAPUI5应用程序中调用Servlet显示404错误 [英] Calling Servlet in SAPUI5 application shows 404 error

查看:93
本文介绍了在SAPUI5应用程序中调用Servlet显示404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了SAPUI5应用程序,并尝试使用servlet来实现某些服务器端功能. 我已从此 教程

中获取了指导

我使用从SAPUI5控制器到Servlet的JQuery ajax调用,该调用在我的本地开发环境(即Eclipse Neon,localhost)上运行良好.

//Name of servlet is GetUserServlet , mapping defined in web.xml 

 $.get('GetUserServlet', {
                            userName : "Hello World"
                         }, function(responseText) {
                          alert(responseText);       
  });

此Ajax调用成功调用了servlet(状态为200),并且当我在本地计算机上从Eclipse运行时,Hello World会收到警报.基本上,我在servlet参数 userName 值中捕获并发送回控制器js文件

string text = request.getParameter("username");
response.getWriter().write(text );

但是,当将此应用程序部署到ABAP服务器时,对Servlet的Ajax调用会抛出404(未找到错误),如Chrome开发者工具的网络控制台中所示.

有人在ABAP上部署了具有Servlet功能的SAPUI5应用程序吗?

这是路径问题吗?

请告知错误原因或提示以解决此问题.

解决方案

您正在将事情混为一谈. UI5应用程序只是一个前端组件,在您的情况下,它与后端JEE应用程序(包含您的servlet)进行通信.我假设您正在例如在本地部署servlet + UI5应用程序. Tomcat实例(或任何其他Web容器).您不能将Java应用程序部署到BSP存储库.

您从SCN链接的页面引用了旧的 ABAP BSP功能(现已过时; BSP存储库仅用于存储UI5应用程序的静态文件).

将JEE应用程序(例如WAR)部署到ABAP后端的唯一方法是,如果后端实际上是

否则,如果您只有普通的ABAP系统,则有以下可能性:

  • ABAP中转换您的Servlet REST服务 JCo(RFC)或通过其他某种机制(SOAP,REST等).
  • 使用tutorial

    I use JQuery ajax call from SAPUI5 controller to Servlet which works fine on my local development environment ( i.e. Eclipse Neon , localhost ).

    //Name of servlet is GetUserServlet , mapping defined in web.xml 
    
     $.get('GetUserServlet', {
                                userName : "Hello World"
                             }, function(responseText) {
                              alert(responseText);       
      });
    

    This Ajax call successfully calls servlet (200 status) and Hello World is alerted when I run this from Eclipse on my local machine. Basically I capture in servlet parameter userName value and send back to controller js file

    string text = request.getParameter("username");
    response.getWriter().write(text );
    

    But when this application is deployed to ABAP server , the Ajax call to servlet throws 404 (not found error) as seen in Network console of Chrome developer tools.

    Has anybody deployed SAPUI5 application with servlet functionality on ABAP ?

    Is it some path issue ?

    Please tell cause of error or hint in direction to solve this issue.

    解决方案

    You are mixing things up a little. The UI5 app is only a front-end component which, in your case, communicates with a backend JEE application (which contains your servlet). I would assume that you are deploying your servlet + UI5 app locally on e.g. a Tomcat instance (or any other web container). You cannot deploy a Java application to the BSP repository.

    The page that you have linked from SCN refers to the old ABAP BSP functionality (which is now obsolete; the BSP repository is simply used to store static files of UI5 applications).

    The only way in which you could deploy a JEE application (e.g. a WAR) to an ABAP backend is if the backend is in fact a ABAP+Java Netweaver installation. To be honest, I have never personally seen such a system in use. In this case, you don't even need to use the BSP repository, you can deploy the JEE backend (servlets and what ever else) and the static resources (the UI5 app) inside the JEE "Engine" of the server.

    Otherwise, if you have only a plain ABAP system, you have the following possibilities:

    • Transform your Servlet in an ABAP REST Service or maybe a Gateway Service (depending on what you want to achieve).
    • Deploy the application to some external java web container or application server. Communicate with the ABAP backend through either JCo (RFC) or through some other mechanism (SOAP, REST, etc).
    • Deploy the application to the SAP Cloud Platform and communicate with the ABAP backend using the SAP Cloud Connector.

    这篇关于在SAPUI5应用程序中调用Servlet显示404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆